generated from finphie/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Utf8Array.Compare実装 #70
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
GetUtf8SequenceLengthusing System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
int A1(byte value)
{
if (value < 0x80)
{
return 1;
}
if ((value & 0xE0) == 0xC0)
{
return 2;
}
if ((value & 0xF0) == 0xE0)
{
return 3;
}
if ((value & 0xF8) == 0xF0)
{
return 4;
}
return default;
}
int A2(byte value)
{
ReadOnlySpan<byte> TrailingBytesForUTF8 = new byte[]
{
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
ref var table = ref MemoryMarshal.GetReference(TrailingBytesForUTF8);
return Unsafe.Add(ref table, (nint)value) + 1;
} <Program>$.<<Main>$>g__A1|0_0(Byte)
L0000: movzx edx, cl
L0003: cmp edx, 0x80
L0009: jge short L0011
L000b: mov eax, 1
L0010: ret
L0011: mov eax, edx
L0013: and eax, 0xe0
L0018: cmp eax, 0xc0
L001d: jne short L0025
L001f: mov eax, 2
L0024: ret
L0025: mov eax, edx
L0027: and eax, 0xf0
L002c: cmp eax, 0xe0
L0031: jne short L0039
L0033: mov eax, 3
L0038: ret
L0039: and edx, 0xf8
L003f: cmp edx, 0xf0
L0045: jne short L004e
L0047: mov eax, 4
L004c: jmp short L0050
L004e: xor eax, eax
L0050: ret
<Program>$.<<Main>$>g__A2|0_1(Byte)
L0000: movzx eax, cl
L0003: mov rdx, 0x19063c30954
L000d: movzx eax, byte ptr [rax+rdx]
L0011: ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.