String.SplitInternal: Remove unnecessary stackalloc (#7623)
authorJustin Van Patten <jvp@justinvp.com>
Sat, 15 Oct 2016 09:58:59 +0000 (02:58 -0700)
committerJan Kotas <jkotas@microsoft.com>
Sat, 15 Oct 2016 09:58:59 +0000 (02:58 -0700)
Simply take the address of the `char` instead of stackallocating a
`char[1]`.

src/mscorlib/src/System/String.Manipulation.cs

index d21c06899bb304c5f9f19c6108cfb98c39b5e405..8c81897d722f62ce111accf707a28a5293c9dadd 100644 (file)
@@ -1001,9 +1001,7 @@ namespace System
         [System.Security.SecuritySafeCritical]
         private unsafe String[] SplitInternal(char separator, int count, StringSplitOptions options)
         {
-            char* pSeparators = stackalloc char[1];
-            pSeparators[0] = separator;
-            return SplitInternal(pSeparators, /*separatorsLength*/ 1, count, options);
+            return SplitInternal(&separator, 1, count, options);
         }
 
         [System.Security.SecuritySafeCritical]