Optimize Char.GetUnicodeCategory and related checks by pentp · Pull Request #20864 · dotnet/coreclr (original) (raw)

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).

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).

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.

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.