Remove unsafe code from String.Join (#44126)
authorStephen Toub <stoub@microsoft.com>
Mon, 2 Nov 2020 02:18:01 +0000 (21:18 -0500)
committerGitHub <noreply@github.com>
Mon, 2 Nov 2020 02:18:01 +0000 (21:18 -0500)
commite10f771b304d47ca5b5be2f1a851e53e0f03da45
treed01a8f04b206b6e570e80d72902b8cc330883d43
parentdf8e3f629afcf24e222b3d10d6c1061e4234b17e
Remove unsafe code from String.Join (#44126)

* Remove unsafe code from String.Join

- Use a span for the separator to share the same code across a char separator and string separator, rather than using pointers.
- Consolidate argument validation for the value/startIndex/count overloads into one shared helper
- Change indexing to use standard 0 to values.Length for loop to eliminate bounds checking on span accesses

* Update src/libraries/System.Private.CoreLib/src/System/String.Manipulation.cs
src/libraries/System.Private.CoreLib/src/System/String.Manipulation.cs