Skip to content

Commit

Permalink
Clean up Uri.UnescapeDataString (dotnet/corefx#42225)
Browse files Browse the repository at this point in the history
- Use string.IndexOf rather than an open-coded, unsafe loop.
- Avoid an unnecessary SequenceEquals at the end: we're only at this point if a `%` was found highlighting that something escaped was found.
- Use stack memory for smaller inputs if possible, to avoid unnecessary ArrayPool interaction
- Remove an unnecessary argument to a helper function.
- Fix ValueStringBuilder.Grow to only copy the contained data.

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
  • Loading branch information
stephentoub authored and dotnet-bot committed Oct 31, 2019
1 parent f4a8863 commit 8b223f2
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ private void Grow(int additionalCapacityBeyondPos)

char[] poolArray = ArrayPool<char>.Shared.Rent(Math.Max(_pos + additionalCapacityBeyondPos, _chars.Length * 2));

_chars.CopyTo(poolArray);
_chars.Slice(0, _pos).CopyTo(poolArray);

char[]? toReturn = _arrayToReturnToPool;
_chars = _arrayToReturnToPool = poolArray;
Expand Down

0 comments on commit 8b223f2

Please sign in to comment.