Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

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 jkotas committed Oct 31, 2019
1 parent 3d02d93 commit 368d8a8
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 368d8a8

Please sign in to comment.