-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Optimize Char.GetUnicodeCategory and related checks #20864
Conversation
@dotnet-bot test Ubuntu x64 Checked CoreFX Tests |
Can this be also applicable to CharUnicodeInfoData and avoid pinning by using |
Only partially - currently only |
@@ -75,20 +75,20 @@ namespace System | |||
// Return true for all characters below or equal U+00ff, which is ASCII + Latin-1 Supplement. | |||
private static bool IsLatin1(char ch) | |||
{ | |||
return (ch <= '\x00ff'); | |||
return (uint)ch <= '\x00ff'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may be able to shave a bounds check by comparing with 0x100 here (have not verified it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried it, didn't help. Also tried to switch the order. I think there was some special way to write this comparison so that Roslyn encodes it in a way that jit recognises (it's used in number parsing if remember correctly).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pentp How do those casts to uint
help? Disassembly seems almost identical: SharpLab.io.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping they would help avoid a range check, but it didn't work.
@dotnet-bot test this please |
@dotnet-bot test OSX10.12 x64 Checked Innerloop Build and Test |
…0864) Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
…0864) Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
…0864) Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
@jkotas CharUnicodeInfoData.cs file mentions a script named GenUnicodeProp.pl that is used to generate the file - where could I find this script? |
@pentp you can find the script here https://1drv.ms/f/s!AhP2SwMuINnCjORSJkPdx8NQfMDf9A |
@tarekgh Would it make sense to commit the script into the repo? |
I was holding on doing that because I wanted to re-write and also not using using perl. Note that this script produce the desktop generated bin files too. if you think it is ok to have in the repo with the current state I don't mind putting there. |
Perfect is the enemy of good enough. |
I'll try rewriting it in C# (excluding desktop bin parts) and then try to refactor the output to use |
…0864) Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
The static data change is inspired by #20768 and range checks are changed to a single conditional instead of multiple branches.
I didn't do perf tests, but asm diffs had only wins.