Skip to content

Remove unsafe code from String.Join#44126

Merged
stephentoub merged 2 commits intodotnet:masterfrom
stephentoub:unsafestringjoin
Nov 2, 2020
Merged

Remove unsafe code from String.Join#44126
stephentoub merged 2 commits intodotnet:masterfrom
stephentoub:unsafestringjoin

Conversation

@stephentoub
Copy link
Member

  • 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
  • Used ThrowHelper in places we already had the relevant defines in place

cc: @GrabYourPitchforks

- 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
@stephentoub stephentoub merged commit e10f771 into dotnet:master Nov 2, 2020
@stephentoub stephentoub deleted the unsafestringjoin branch November 2, 2020 02:18
@ghost ghost locked as resolved and limited conversation to collaborators Dec 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants