This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Use ordinal when checking for hex prefix #5027
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In general lingustic comparsion is slower than ordinal comparision. When using ICU for globalization, the lingustic StartsWith code path actually ends up doing a lot of work inside ICU itself. While we'll try to make things better (see dotnet/corefx#3672) for common cases like ASCII only, if code doesn't need ligustic comparision the best practice is to not request it. BaseNumberConverter was using a lingustic StartsWith to detect a hex prefix when trying to parse a number but it is better served by just always using ordinal comparisons. This results in a ~35% QPS improvement in some very barebones ASP.NET scenarios (like the one outlined in richardkiene/CoreCLRWebAPISample) on my local machine.
@ianhays or @krwq Can you please take a look? /cc @richardkiene |
LGTM. Nice little fix :) Thanks, Matt. |
ellismg
added a commit
that referenced
this pull request
Dec 17, 2015
Use ordinal when checking for hex prefix
That might be naive question, but shouldn't
be
i.e. check for prefix if flag is true? |
@ianhays I'm wondering what @ojosdegris wondered too. This is intact in the current version. |
Well it's consistent with what was there before this commit, but it does seem like an issue. |
The .NET Framework version does this too so this may be bug compatibility. |
Then again, if bug compatibility is to be maintained, |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In general lingustic comparsion is slower than ordinal comparision.
When using ICU for globalization, the lingustic StartsWith code path
actually ends up doing a lot of work inside ICU itself. While we'll try
to make things better (see dotnet/corefx#3672) for common cases like
ASCII only, if code doesn't need ligustic comparision the best practice
is to not request it.
BaseNumberConverter was using a lingustic StartsWith to detect a hex
prefix when trying to parse a number but it is better served by just
always using ordinal comparisons.
This results in a ~35% QPS improvement in some very barebones ASP.NET
scenarios (like the one outlined in richardkiene/CoreCLRWebAPISample) on
my local machine.