{"action":"created","comment":{"url":"https://api.github.com/repos/aspnet/FileSystem/pulls/comments/23404598","id":23404598,"diff_hunk":"@@ -0,0 +1,277 @@\n+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.\n+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\n+\n+using System.Collections.Generic;\n+using System.IO;\n+using Microsoft.Framework.FileSystemGlobbing.Abstractions;\n+\n+namespace Microsoft.Framework.FileSystemGlobbing.Infrastructure\n+{\n+    public class MatcherContext\n+    {\n+        public MatcherContext(Matcher matcher, DirectoryInfoBase directoryInfo)\n+        {\n+            Matcher = matcher;\n+            DirectoryInfo = directoryInfo;\n+            foreach (var pattern in matcher.IncludePatterns)\n+            {\n+                if (pattern.Contains == null)\n+                {\n+                    IncludePatternContexts.Add(new PatternContextLinearInclude(this, pattern));\n+                }\n+                else\n+                {\n+                    IncludePatternContexts.Add(new PatternContextRaggedInclude(this, pattern));\n+                }\n+            }\n+            foreach (var pattern in matcher.ExcludePatterns)\n+            {\n+                if (pattern.Contains == null)\n+                {\n+                    ExcludePatternContexts.Add(new PatternContextLinearExclude(this, pattern));\n+                }\n+                else\n+                {\n+                    ExcludePatternContexts.Add(new PatternContextRaggedExclude(this, pattern));\n+                }\n+            }\n+        }\n+\n+        public Matcher Matcher { get; }\n+        public DirectoryInfoBase DirectoryInfo { get; }\n+        public IList<PatternContextBase> IncludePatternContexts { get; } = new List<PatternContextBase>();\n+        public IList<PatternContextBase> ExcludePatternContexts { get; } = new List<PatternContextBase>();\n+        public List<string> Files { get; private set; }\n+\n+        public FrameData Frame;\n+        public Stack<FrameData> FrameStack = new Stack<FrameData>();\n+\n+        public PatternMatchingResult Execute()\n+        {\n+            Files = new List<string>();\n+\n+            Frame.Stage = Stage.Complete;\n+            PushFrame(Stage.Predicting, DirectoryInfo);\n+\n+            while (Frame.Stage != Stage.Complete)\n+            {\n+                DoPredicting();\n+                DoEnumerating();\n+                DoRecursion();\n+            }\n+\n+            return new PatternMatchingResult(Files);\n+        }\n+\n+        private void DoPredicting()\n+        {\n+            if (Frame.Stage != Stage.Predicting)\n+            {\n+                return;\n+            }\n+            //foreach (var patternContext in IncludePatternContexts)\n+            //{\n+            //    patternContext.PredictInclude();\n+            //}\n+            //foreach (var patternContext in ExcludePatternContexts)\n+            //{\n+            //    //patternContext.PredictExclude();\n+            //}\n+            Frame.Stage = Stage.Enumerating;\n+        }\n+\n+        private void DoEnumerating()\n+        {\n+            if (Frame.Stage != Stage.Enumerating)\n+            {\n+                return;\n+            }\n+            foreach (var fileSystemInfo in Frame.DirectoryInfo.EnumerateFileSystemInfos(\n+                \"*\",\n+                SearchOption.TopDirectoryOnly))\n+            {\n+                var directoryInfo = fileSystemInfo as DirectoryInfoBase;\n+                if (directoryInfo != null)\n+                {\n+                    var include = false;\n+                    foreach (var pattern in IncludePatternContexts)\n+                    {\n+                        if (pattern.Test(directoryInfo))\n+                        {\n+                            include = true;\n+                            break;\n+                        }\n+                    }\n+                    if (include)\n+                    {\n+                        foreach (var pattern in ExcludePatternContexts)\n+                        {\n+                            if (pattern.Test(directoryInfo))\n+                            {\n+                                include = false;\n+                                break;\n+                            }\n+                        }\n+                    }\n+                    if (include)\n+                    {\n+                        if (Frame.ActualDirectories == null)\n+                        {\n+                            Frame.ActualDirectories = new List<DirectoryInfoBase>();\n+                        }\n+                        Frame.ActualDirectories.Add(directoryInfo);\n+                    }\n+                    continue;\n+                }\n+                var fileInfo = fileSystemInfo as FileInfoBase;\n+                if (fileInfo != null)\n+                {\n+                    var include = false;\n+                    foreach (var pattern in IncludePatternContexts)","path":"src/Microsoft.Framework.FileSystemGlobbing/Infrastructure/MatcherContext.cs","position":130,"original_position":130,"commit_id":"7bb4d364fbef2cfe1355f742fa43a51314f00a3d","original_commit_id":"8a34aeb049436f4192a1c86bbbed4fe0ad0a0cda","user":{"login":"pranavkm","id":174281,"avatar_url":"https://avatars.githubusercontent.com/u/174281?v=3","gravatar_id":"","url":"https://api.github.com/users/pranavkm","html_url":"https://github.com/pranavkm","followers_url":"https://api.github.com/users/pranavkm/followers","following_url":"https://api.github.com/users/pranavkm/following{/other_user}","gists_url":"https://api.github.com/users/pranavkm/gists{/gist_id}","starred_url":"https://api.github.com/users/pranavkm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pranavkm/subscriptions","organizations_url":"https://api.github.com/users/pranavkm/orgs","repos_url":"https://api.github.com/users/pranavkm/repos","events_url":"https://api.github.com/users/pranavkm/events{/privacy}","received_events_url":"https://api.github.com/users/pranavkm/received_events","type":"User","site_admin":false},"body":"Was that actually measured or is it hypothetical? We are doing file system scanning (and potentially reading files). So I'd be surprised if Linq shows up in the profiler with this.","created_at":"2015-01-22T19:55:41Z","updated_at":"2015-01-22T19:55:41Z","html_url":"https://github.com/aspnet/FileSystem/pull/50#discussion_r23404598","pull_request_url":"https://api.github.com/repos/aspnet/FileSystem/pulls/50","_links":{"self":{"href":"https://api.github.com/repos/aspnet/FileSystem/pulls/comments/23404598"},"html":{"href":"https://github.com/aspnet/FileSystem/pull/50#discussion_r23404598"},"pull_request":{"href":"https://api.github.com/repos/aspnet/FileSystem/pulls/50"}}},"pull_request":{"url":"https://api.github.com/repos/aspnet/FileSystem/pulls/50","id":27863981,"html_url":"https://github.com/aspnet/FileSystem/pull/50","diff_url":"https://github.com/aspnet/FileSystem/pull/50.diff","patch_url":"https://github.com/aspnet/FileSystem/pull/50.patch","issue_url":"https://api.github.com/repos/aspnet/FileSystem/issues/50","number":50,"state":"closed","locked":false,"title":"Begin integrating FileSystemGlobbing","user":{"login":"troydai","id":1329240,"avatar_url":"https://avatars.githubusercontent.com/u/1329240?v=3","gravatar_id":"","url":"https://api.github.com/users/troydai","html_url":"https://github.com/troydai","followers_url":"https://api.github.com/users/troydai/followers","following_url":"https://api.github.com/users/troydai/following{/other_user}","gists_url":"https://api.github.com/users/troydai/gists{/gist_id}","starred_url":"https://api.github.com/users/troydai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/troydai/subscriptions","organizations_url":"https://api.github.com/users/troydai/orgs","repos_url":"https://api.github.com/users/troydai/repos","events_url":"https://api.github.com/users/troydai/events{/privacy}","received_events_url":"https://api.github.com/users/troydai/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-01-22T18:07:05Z","updated_at":"2015-01-22T19:55:41Z","closed_at":"2015-01-22T18:46:28Z","merged_at":"2015-01-22T18:46:28Z","merge_commit_sha":"16d4a28e7a31aca329f2880e50f1f2ad8496233e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aspnet/FileSystem/pulls/50/commits","review_comments_url":"https://api.github.com/repos/aspnet/FileSystem/pulls/50/comments","review_comment_url":"https://api.github.com/repos/aspnet/FileSystem/pulls/comments/{number}","comments_url":"https://api.github.com/repos/aspnet/FileSystem/issues/50/comments","statuses_url":"https://api.github.com/repos/aspnet/FileSystem/statuses/7bb4d364fbef2cfe1355f742fa43a51314f00a3d","head":{"label":"aspnet:filesystemglobbing","ref":"filesystemglobbing","sha":"7bb4d364fbef2cfe1355f742fa43a51314f00a3d","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":16161950,"name":"FileSystem","full_name":"aspnet/FileSystem","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/FileSystem","description":"Abstraction of file system APIs.","fork":false,"url":"https://api.github.com/repos/aspnet/FileSystem","forks_url":"https://api.github.com/repos/aspnet/FileSystem/forks","keys_url":"https://api.github.com/repos/aspnet/FileSystem/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/FileSystem/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/FileSystem/teams","hooks_url":"https://api.github.com/repos/aspnet/FileSystem/hooks","issue_events_url":"https://api.github.com/repos/aspnet/FileSystem/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/FileSystem/events","assignees_url":"https://api.github.com/repos/aspnet/FileSystem/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/FileSystem/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/FileSystem/tags","blobs_url":"https://api.github.com/repos/aspnet/FileSystem/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/FileSystem/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/FileSystem/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/FileSystem/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/FileSystem/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/FileSystem/languages","stargazers_url":"https://api.github.com/repos/aspnet/FileSystem/stargazers","contributors_url":"https://api.github.com/repos/aspnet/FileSystem/contributors","subscribers_url":"https://api.github.com/repos/aspnet/FileSystem/subscribers","subscription_url":"https://api.github.com/repos/aspnet/FileSystem/subscription","commits_url":"https://api.github.com/repos/aspnet/FileSystem/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/FileSystem/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/FileSystem/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/FileSystem/issues/comments/{number}","contents_url":"https://api.github.com/repos/aspnet/FileSystem/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/FileSystem/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/FileSystem/merges","archive_url":"https://api.github.com/repos/aspnet/FileSystem/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/FileSystem/downloads","issues_url":"https://api.github.com/repos/aspnet/FileSystem/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/FileSystem/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/FileSystem/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/FileSystem/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/FileSystem/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/FileSystem/releases{/id}","created_at":"2014-01-23T04:09:34Z","updated_at":"2015-01-22T18:54:34Z","pushed_at":"2015-01-22T18:54:33Z","git_url":"git://github.com/aspnet/FileSystem.git","ssh_url":"git@github.com:aspnet/FileSystem.git","clone_url":"https://github.com/aspnet/FileSystem.git","svn_url":"https://github.com/aspnet/FileSystem","homepage":"","size":1027,"stargazers_count":49,"watchers_count":49,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":20,"mirror_url":null,"open_issues_count":24,"forks":20,"open_issues":24,"watchers":49,"default_branch":"dev"}},"base":{"label":"aspnet:dev","ref":"dev","sha":"7ad7b3db3d49038a5c5e96a66201850ea423b557","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":16161950,"name":"FileSystem","full_name":"aspnet/FileSystem","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/FileSystem","description":"Abstraction of file system APIs.","fork":false,"url":"https://api.github.com/repos/aspnet/FileSystem","forks_url":"https://api.github.com/repos/aspnet/FileSystem/forks","keys_url":"https://api.github.com/repos/aspnet/FileSystem/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/FileSystem/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/FileSystem/teams","hooks_url":"https://api.github.com/repos/aspnet/FileSystem/hooks","issue_events_url":"https://api.github.com/repos/aspnet/FileSystem/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/FileSystem/events","assignees_url":"https://api.github.com/repos/aspnet/FileSystem/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/FileSystem/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/FileSystem/tags","blobs_url":"https://api.github.com/repos/aspnet/FileSystem/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/FileSystem/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/FileSystem/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/FileSystem/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/FileSystem/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/FileSystem/languages","stargazers_url":"https://api.github.com/repos/aspnet/FileSystem/stargazers","contributors_url":"https://api.github.com/repos/aspnet/FileSystem/contributors","subscribers_url":"https://api.github.com/repos/aspnet/FileSystem/subscribers","subscription_url":"https://api.github.com/repos/aspnet/FileSystem/subscription","commits_url":"https://api.github.com/repos/aspnet/FileSystem/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/FileSystem/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/FileSystem/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/FileSystem/issues/comments/{number}","contents_url":"https://api.github.com/repos/aspnet/FileSystem/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/FileSystem/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/FileSystem/merges","archive_url":"https://api.github.com/repos/aspnet/FileSystem/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/FileSystem/downloads","issues_url":"https://api.github.com/repos/aspnet/FileSystem/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/FileSystem/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/FileSystem/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/FileSystem/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/FileSystem/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/FileSystem/releases{/id}","created_at":"2014-01-23T04:09:34Z","updated_at":"2015-01-22T18:54:34Z","pushed_at":"2015-01-22T18:54:33Z","git_url":"git://github.com/aspnet/FileSystem.git","ssh_url":"git@github.com:aspnet/FileSystem.git","clone_url":"https://github.com/aspnet/FileSystem.git","svn_url":"https://github.com/aspnet/FileSystem","homepage":"","size":1027,"stargazers_count":49,"watchers_count":49,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":20,"mirror_url":null,"open_issues_count":24,"forks":20,"open_issues":24,"watchers":49,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/aspnet/FileSystem/pulls/50"},"html":{"href":"https://github.com/aspnet/FileSystem/pull/50"},"issue":{"href":"https://api.github.com/repos/aspnet/FileSystem/issues/50"},"comments":{"href":"https://api.github.com/repos/aspnet/FileSystem/issues/50/comments"},"review_comments":{"href":"https://api.github.com/repos/aspnet/FileSystem/pulls/50/comments"},"review_comment":{"href":"https://api.github.com/repos/aspnet/FileSystem/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/aspnet/FileSystem/pulls/50/commits"},"statuses":{"href":"https://api.github.com/repos/aspnet/FileSystem/statuses/7bb4d364fbef2cfe1355f742fa43a51314f00a3d"}}}}