{"action":"created","comment":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/comments/41388995","id":41388995,"diff_hunk":"@@ -2,457 +2,373 @@\n // Licensed under the MIT license. See LICENSE file in the project root for full license information.\n \n using System.Diagnostics;\n-using System.Diagnostics.Contracts;\n using System.Runtime.InteropServices;\n-using System.Security;\n using System.Text;\n \n namespace System.IO\n {\n-    // ABOUT:\n-    // Helps with path normalization; support allocating on the stack or heap\n-    // \n-    // PathHelper can't stackalloc the array for obvious reasons; you must pass\n-    // in an array of chars allocated on the stack.\n-    // \n-    // USAGE:\n-    // Suppose you need to represent a char array of length len. Then this is the\n-    // suggested way to instantiate PathHelper:\n-    // ***************************************************************************\n-    // PathHelper pathHelper;\n-    // if (charArrayLength less than stack alloc threshold == Path.MaxPath)\n-    //     char* arrayPtr = stackalloc char[Path.MaxPath];\n-    //     pathHelper = new PathHelper(arrayPtr);\n-    // else\n-    //     pathHelper = new PathHelper(capacity, maxPath);\n-    // ***************************************************************************\n-    //\n-    // note in the StringBuilder ctor:\n-    // - maxPath may be greater than Path.MaxPath (for isolated storage)\n-    // - capacity may be greater than maxPath. This is even used for non-isolated\n-    //   storage scenarios where we want to temporarily allow strings greater \n-    //   than Path.MaxPath if they can be normalized down to Path.MaxPath. This\n-    //   can happen if the path contains escape characters \"..\".\n-    // \n+    /// <summary>\n+    /// Wrapper to help with path normalization.\n+    /// </summary>\n     unsafe internal class PathHelper\n-    {   // should not be serialized\n-        // maximum size, max be greater than max path if contains escape sequence\n-        private int m_capacity;\n-        // current length (next character position)\n-        private int m_length;\n-        // max path, may be less than capacity\n-        private int m_maxPath;\n-\n-        // ptr to stack alloc'd array of chars\n-        [SecurityCritical]\n-        private char* m_arrayPtr;\n-\n-        // StringBuilder\n-        private StringBuilder m_sb;\n-\n-        // whether to operate on stack alloc'd or heap alloc'd array \n-        private bool useStackAlloc;\n-\n-        // Whether to skip calls to Win32Native.GetLongPathName becasue we tried before and failed:\n-        private bool doNotTryExpandShortFileName;\n-\n-        /// <summary>\n-        /// Instantiates a PathHelper with a stack alloc'd array of chars.\n-        /// NOTE: This cannot grow past the initial length and will always fail if over MAX_PATH.\n-        /// </summary>\n-        [System.Security.SecurityCritical]\n-        internal PathHelper(char* charArrayPtr, int length)\n-        {\n-            Contract.Requires(charArrayPtr != null);\n-            // force callers to be aware of this\n-            Contract.Requires(length == Path.MaxPath);\n-\n-            this.m_arrayPtr = charArrayPtr;\n-            this.m_capacity = length;\n-            this.m_maxPath = Path.MaxPath;\n-            useStackAlloc = true;\n-            doNotTryExpandShortFileName = false;\n-        }\n+    {\n+        // This should cover the vast majority of usages without adding undue memory pressure\n+        private const int MAX_BUILDER_SIZE = 1024;\n \n-        // Instantiates a PathHelper with a heap alloc'd array of ints. Will create a StringBuilder\n-        internal PathHelper(int capacity, int maxPath)\n-        {\n-            this.m_sb = new StringBuilder(capacity);\n-            this.m_capacity = capacity;\n-            this.m_maxPath = maxPath;\n-            doNotTryExpandShortFileName = false;\n-        }\n+        // Can't be over 8.3 and be a short name\n+        private const int MAX_SHORT_NAME = 12;","path":"src/System.Runtime.Extensions/src/System/IO/PathHelper.Windows.cs","position":91,"original_position":91,"commit_id":"792c3c5d6dfb13da873fa4bbdd3e0f4e6e4d843f","original_commit_id":"792c3c5d6dfb13da873fa4bbdd3e0f4e6e4d843f","user":{"login":"stephentoub","id":2642209,"avatar_url":"https://avatars.githubusercontent.com/u/2642209?v=3","gravatar_id":"","url":"https://api.github.com/users/stephentoub","html_url":"https://github.com/stephentoub","followers_url":"https://api.github.com/users/stephentoub/followers","following_url":"https://api.github.com/users/stephentoub/following{/other_user}","gists_url":"https://api.github.com/users/stephentoub/gists{/gist_id}","starred_url":"https://api.github.com/users/stephentoub/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephentoub/subscriptions","organizations_url":"https://api.github.com/users/stephentoub/orgs","repos_url":"https://api.github.com/users/stephentoub/repos","events_url":"https://api.github.com/users/stephentoub/events{/privacy}","received_events_url":"https://api.github.com/users/stephentoub/received_events","type":"User","site_admin":false},"body":"Nit: MaxShortName","created_at":"2015-10-07T13:25:48Z","updated_at":"2015-10-07T13:25:48Z","html_url":"https://github.com/dotnet/corefx/pull/3549#discussion_r41388995","pull_request_url":"https://api.github.com/repos/dotnet/corefx/pulls/3549","_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments/41388995"},"html":{"href":"https://github.com/dotnet/corefx/pull/3549#discussion_r41388995"},"pull_request":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/3549"}}},"pull_request":{"url":"https://api.github.com/repos/dotnet/corefx/pulls/3549","id":46361341,"html_url":"https://github.com/dotnet/corefx/pull/3549","diff_url":"https://github.com/dotnet/corefx/pull/3549.diff","patch_url":"https://github.com/dotnet/corefx/pull/3549.patch","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/3549","number":3549,"state":"open","locked":false,"title":"Address perf for GetFullPath and defer to OS.","user":{"login":"JeremyKuhne","id":8184940,"avatar_url":"https://avatars.githubusercontent.com/u/8184940?v=3","gravatar_id":"","url":"https://api.github.com/users/JeremyKuhne","html_url":"https://github.com/JeremyKuhne","followers_url":"https://api.github.com/users/JeremyKuhne/followers","following_url":"https://api.github.com/users/JeremyKuhne/following{/other_user}","gists_url":"https://api.github.com/users/JeremyKuhne/gists{/gist_id}","starred_url":"https://api.github.com/users/JeremyKuhne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JeremyKuhne/subscriptions","organizations_url":"https://api.github.com/users/JeremyKuhne/orgs","repos_url":"https://api.github.com/users/JeremyKuhne/repos","events_url":"https://api.github.com/users/JeremyKuhne/events{/privacy}","received_events_url":"https://api.github.com/users/JeremyKuhne/received_events","type":"User","site_admin":false},"body":"@vancem, @KrzysztofCwalina, @stephentoub, @Priya91 \r\n\r\nThis change attempts to limit the number of allocations made when evaluating\r\nfull paths. This is particularly important when Windows paths can be way over\r\nthe historical max of 260 characters. (The new max is over 32K)\r\n\r\nWe no longer kick paths in Windows that are valid, outside of paths with colons\r\nthat are not directory separators. (This has the effect of blocking alternate\r\ndata stream access- which is a legacy behavior.)\r\n\r\nWhen creating directories, we still drop the trailing separator, which causes\r\ntrailing whitespace to be trimmed. This makes it particularly difficult to create\r\npaths with trailing spaces in .NET, which is still desirable as most code has\r\na tough time dealing with this scenario. We'll open them fine now, which hits\r\nthe above point of not kicking valid legacy paths (paths that don't require\r\nextended syntax).\r\n\r\nSeveral simplifications to the logic were made, including moving relative segment\r\nevaluation to shared code and calling it directly when getting directory names\r\nrather than relying on the not-so-obvious prior behavior of GetFullPath without\r\n\"full checks\".","created_at":"2015-09-30T04:53:46Z","updated_at":"2015-10-07T13:25:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1b4adfc7255ea58a50b62a52ee4c7f52510e2da4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dotnet/corefx/pulls/3549/commits","review_comments_url":"https://api.github.com/repos/dotnet/corefx/pulls/3549/comments","review_comment_url":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/3549/comments","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/792c3c5d6dfb13da873fa4bbdd3e0f4e6e4d843f","head":{"label":"JeremyKuhne:GetFullPath","ref":"GetFullPath","sha":"792c3c5d6dfb13da873fa4bbdd3e0f4e6e4d843f","user":{"login":"JeremyKuhne","id":8184940,"avatar_url":"https://avatars.githubusercontent.com/u/8184940?v=3","gravatar_id":"","url":"https://api.github.com/users/JeremyKuhne","html_url":"https://github.com/JeremyKuhne","followers_url":"https://api.github.com/users/JeremyKuhne/followers","following_url":"https://api.github.com/users/JeremyKuhne/following{/other_user}","gists_url":"https://api.github.com/users/JeremyKuhne/gists{/gist_id}","starred_url":"https://api.github.com/users/JeremyKuhne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JeremyKuhne/subscriptions","organizations_url":"https://api.github.com/users/JeremyKuhne/orgs","repos_url":"https://api.github.com/users/JeremyKuhne/repos","events_url":"https://api.github.com/users/JeremyKuhne/events{/privacy}","received_events_url":"https://api.github.com/users/JeremyKuhne/received_events","type":"User","site_admin":false},"repo":{"id":30339123,"name":"corefx","full_name":"JeremyKuhne/corefx","owner":{"login":"JeremyKuhne","id":8184940,"avatar_url":"https://avatars.githubusercontent.com/u/8184940?v=3","gravatar_id":"","url":"https://api.github.com/users/JeremyKuhne","html_url":"https://github.com/JeremyKuhne","followers_url":"https://api.github.com/users/JeremyKuhne/followers","following_url":"https://api.github.com/users/JeremyKuhne/following{/other_user}","gists_url":"https://api.github.com/users/JeremyKuhne/gists{/gist_id}","starred_url":"https://api.github.com/users/JeremyKuhne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JeremyKuhne/subscriptions","organizations_url":"https://api.github.com/users/JeremyKuhne/orgs","repos_url":"https://api.github.com/users/JeremyKuhne/repos","events_url":"https://api.github.com/users/JeremyKuhne/events{/privacy}","received_events_url":"https://api.github.com/users/JeremyKuhne/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/JeremyKuhne/corefx","description":"This repo contains the foundational libraries that make up the .NET Core development stack.","fork":true,"url":"https://api.github.com/repos/JeremyKuhne/corefx","forks_url":"https://api.github.com/repos/JeremyKuhne/corefx/forks","keys_url":"https://api.github.com/repos/JeremyKuhne/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JeremyKuhne/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JeremyKuhne/corefx/teams","hooks_url":"https://api.github.com/repos/JeremyKuhne/corefx/hooks","issue_events_url":"https://api.github.com/repos/JeremyKuhne/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/JeremyKuhne/corefx/events","assignees_url":"https://api.github.com/repos/JeremyKuhne/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/JeremyKuhne/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/JeremyKuhne/corefx/tags","blobs_url":"https://api.github.com/repos/JeremyKuhne/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JeremyKuhne/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JeremyKuhne/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/JeremyKuhne/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JeremyKuhne/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/JeremyKuhne/corefx/languages","stargazers_url":"https://api.github.com/repos/JeremyKuhne/corefx/stargazers","contributors_url":"https://api.github.com/repos/JeremyKuhne/corefx/contributors","subscribers_url":"https://api.github.com/repos/JeremyKuhne/corefx/subscribers","subscription_url":"https://api.github.com/repos/JeremyKuhne/corefx/subscription","commits_url":"https://api.github.com/repos/JeremyKuhne/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/JeremyKuhne/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/JeremyKuhne/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/JeremyKuhne/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/JeremyKuhne/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/JeremyKuhne/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JeremyKuhne/corefx/merges","archive_url":"https://api.github.com/repos/JeremyKuhne/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JeremyKuhne/corefx/downloads","issues_url":"https://api.github.com/repos/JeremyKuhne/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/JeremyKuhne/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/JeremyKuhne/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/JeremyKuhne/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JeremyKuhne/corefx/labels{/name}","releases_url":"https://api.github.com/repos/JeremyKuhne/corefx/releases{/id}","created_at":"2015-02-05T05:16:58Z","updated_at":"2015-05-08T20:58:22Z","pushed_at":"2015-10-06T23:28:02Z","git_url":"git://github.com/JeremyKuhne/corefx.git","ssh_url":"git@github.com:JeremyKuhne/corefx.git","clone_url":"https://github.com/JeremyKuhne/corefx.git","svn_url":"https://github.com/JeremyKuhne/corefx","homepage":"","size":32733,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dotnet:master","ref":"master","sha":"9e04458a3c01ad5fc22fbb3c30a5b9f1bbbf6856","user":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"repo":{"id":26295345,"name":"corefx","full_name":"dotnet/corefx","owner":{"login":"dotnet","id":9141961,"avatar_url":"https://avatars.githubusercontent.com/u/9141961?v=3","gravatar_id":"","url":"https://api.github.com/users/dotnet","html_url":"https://github.com/dotnet","followers_url":"https://api.github.com/users/dotnet/followers","following_url":"https://api.github.com/users/dotnet/following{/other_user}","gists_url":"https://api.github.com/users/dotnet/gists{/gist_id}","starred_url":"https://api.github.com/users/dotnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dotnet/subscriptions","organizations_url":"https://api.github.com/users/dotnet/orgs","repos_url":"https://api.github.com/users/dotnet/repos","events_url":"https://api.github.com/users/dotnet/events{/privacy}","received_events_url":"https://api.github.com/users/dotnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dotnet/corefx","description":"This repo contains the .NET Core foundational libraries, called CoreFX. It includes classes for collections, file systems, console, XML, async and many others.","fork":false,"url":"https://api.github.com/repos/dotnet/corefx","forks_url":"https://api.github.com/repos/dotnet/corefx/forks","keys_url":"https://api.github.com/repos/dotnet/corefx/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dotnet/corefx/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dotnet/corefx/teams","hooks_url":"https://api.github.com/repos/dotnet/corefx/hooks","issue_events_url":"https://api.github.com/repos/dotnet/corefx/issues/events{/number}","events_url":"https://api.github.com/repos/dotnet/corefx/events","assignees_url":"https://api.github.com/repos/dotnet/corefx/assignees{/user}","branches_url":"https://api.github.com/repos/dotnet/corefx/branches{/branch}","tags_url":"https://api.github.com/repos/dotnet/corefx/tags","blobs_url":"https://api.github.com/repos/dotnet/corefx/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dotnet/corefx/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dotnet/corefx/git/refs{/sha}","trees_url":"https://api.github.com/repos/dotnet/corefx/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dotnet/corefx/statuses/{sha}","languages_url":"https://api.github.com/repos/dotnet/corefx/languages","stargazers_url":"https://api.github.com/repos/dotnet/corefx/stargazers","contributors_url":"https://api.github.com/repos/dotnet/corefx/contributors","subscribers_url":"https://api.github.com/repos/dotnet/corefx/subscribers","subscription_url":"https://api.github.com/repos/dotnet/corefx/subscription","commits_url":"https://api.github.com/repos/dotnet/corefx/commits{/sha}","git_commits_url":"https://api.github.com/repos/dotnet/corefx/git/commits{/sha}","comments_url":"https://api.github.com/repos/dotnet/corefx/comments{/number}","issue_comment_url":"https://api.github.com/repos/dotnet/corefx/issues/comments{/number}","contents_url":"https://api.github.com/repos/dotnet/corefx/contents/{+path}","compare_url":"https://api.github.com/repos/dotnet/corefx/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dotnet/corefx/merges","archive_url":"https://api.github.com/repos/dotnet/corefx/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dotnet/corefx/downloads","issues_url":"https://api.github.com/repos/dotnet/corefx/issues{/number}","pulls_url":"https://api.github.com/repos/dotnet/corefx/pulls{/number}","milestones_url":"https://api.github.com/repos/dotnet/corefx/milestones{/number}","notifications_url":"https://api.github.com/repos/dotnet/corefx/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dotnet/corefx/labels{/name}","releases_url":"https://api.github.com/repos/dotnet/corefx/releases{/id}","created_at":"2014-11-06T23:42:48Z","updated_at":"2015-10-07T10:04:18Z","pushed_at":"2015-10-07T13:05:23Z","git_url":"git://github.com/dotnet/corefx.git","ssh_url":"git@github.com:dotnet/corefx.git","clone_url":"https://github.com/dotnet/corefx.git","svn_url":"https://github.com/dotnet/corefx","homepage":"http://dotnet.github.io/core/","size":76338,"stargazers_count":8420,"watchers_count":8420,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1840,"mirror_url":null,"open_issues_count":637,"forks":1840,"open_issues":637,"watchers":8420,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/3549"},"html":{"href":"https://github.com/dotnet/corefx/pull/3549"},"issue":{"href":"https://api.github.com/repos/dotnet/corefx/issues/3549"},"comments":{"href":"https://api.github.com/repos/dotnet/corefx/issues/3549/comments"},"review_comments":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/3549/comments"},"review_comment":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dotnet/corefx/pulls/3549/commits"},"statuses":{"href":"https://api.github.com/repos/dotnet/corefx/statuses/792c3c5d6dfb13da873fa4bbdd3e0f4e6e4d843f"}}}}