Last active
December 7, 2021 13:04
-
-
Save guitarrapc/d132b26417154123d3406f58d7f4ba6d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<Main>g__Operator|4_0 (String, String) | |
L0000 jmp System.String.Equals(System.String, System.String) | |
<Main>g__Equals|4_1 (String, String) | |
L0000 mov rax, 0x7fff58527b68 | |
L000a mov rax, [rax] | |
L000d cmp [rcx], ecx | |
L000f jmp rax | |
<Main>g__EqualsComparer|4_2<T> (T, T) | |
? | |
<Main>g__EqualsComparerString|4_3 (String, String) | |
L0000 mov r8, rcx | |
L0003 mov rax, rdx | |
L0006 mov rcx, 0x1cfdfc42c78 | |
L0010 mov rcx, [rcx] | |
L0013 mov rdx, r8 | |
L0016 mov r8, rax | |
L0019 mov rax, 0x7fff58534f50 | |
L0023 mov rax, [rax] | |
L0026 jmp rax | |
<Main>g__ObjOperator|4_4 (Object, Object) | |
L0000 cmp rcx, rdx | |
L0003 sete al | |
L0006 movzx eax, al | |
L0009 ret | |
<Main>g__ObjEquals|4_5 (Object, Object) | |
L0000 mov rax, [rcx] | |
L0003 mov rax, [rax+0x40] | |
L0007 mov rax, [rax+0x10] | |
L000b jmp rax | |
<Main>g__ObjReferenceEquals|4_6 (String, String) | |
L0000 cmp rcx, rdx | |
L0003 sete al | |
L0006 movzx eax, al | |
L0009 ret | |
<Main>g__OperatorT|4_7<T> (T, T) | |
? | |
EmbeddedAttribute..ctor | |
L0000 ret |
This file contains hidden or 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
foreach (var (s1, s2) in new[] { ("s", "s"), (new String("s"), new String("s")) }) | |
{ | |
"========================================================".Dump(); | |
Operator(s1, s2).Dump("string =="); | |
Equals(s1, s2).Dump("string Equals"); | |
EqualsComparer(s1, s2).Dump("T EqualityComparer"); | |
EqualsComparerString(s1, s2).Dump("string EqualityComparer"); | |
ObjOperator(s1, s2).Dump("obj =="); | |
ObjEquals(s1, s2).Dump("object Equals"); | |
ObjReferenceEquals(s1, s2).Dump("ReferenceEquals"); | |
OperatorT(s1, s2).Dump("T =="); | |
} | |
bool Operator(string l, string r) => l == r; | |
bool Equals(string l, string r) => l.Equals(r); | |
bool EqualsComparer<T>(T l, T r) => EqualityComparer<T>.Default.Equals(l, r); | |
bool EqualsComparerString(string l, string r) => EqualityComparer<string>.Default.Equals(l, r); | |
bool ObjOperator(object l, object r) => l == r; | |
bool ObjEquals(object l, object r) => l.Equals(r); | |
bool ObjReferenceEquals(string l, string r) => Object.ReferenceEquals(l, r); | |
bool OperatorT<T>(T l, T r) where T: class => l == r; |
This file contains hidden or 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
======================================================== | |
string == | |
True | |
string Equals | |
True | |
T EqualityComparer | |
True | |
string EqualityComparer | |
True | |
obj == | |
True | |
object Equals | |
True | |
ReferenceEquals | |
True | |
T == | |
True | |
======================================================== | |
string == | |
True | |
string Equals | |
True | |
T EqualityComparer | |
True | |
string EqualityComparer | |
True | |
obj == | |
False | |
object Equals | |
True | |
ReferenceEquals | |
False | |
T == | |
False |
This file contains hidden or 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
L0000 sub rsp, 0x38 // only this line is `var s1 = "s";` | |
L0004 xor eax, eax // below are all `var s2 = new String("s");` | |
L0006 mov [rsp+0x28], rax | |
L000b mov rdx, 0x1ad70eb3010 | |
L0015 mov rdx, [rdx] | |
L0018 test rdx, rdx | |
L001b jne short L0023 | |
L001d xor ecx, ecx | |
L001f xor eax, eax | |
L0021 jmp short L0033 | |
L0023 cmp [rdx], edx | |
L0025 cmp [rdx], edx | |
L0027 add rdx, 0xc | |
L002b mov rcx, rdx | |
L002e mov eax, 1 | |
L0033 lea rdx, [rsp+0x28] | |
L0038 mov [rdx], rcx | |
L003b mov [rdx+8], eax | |
L003e lea rdx, [rsp+0x28] | |
L0043 xor ecx, ecx | |
L0045 call System.String..ctor(System.ReadOnlySpan`1<Char>) | |
L004a nop | |
L004b add rsp, 0x38 | |
L004f ret |
This file contains hidden or 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
var s1 = "s"; | |
var s2 = new String("s"); |
This file contains hidden or 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
IL_0000 ldstr "s" | |
IL_0005 call String.op_Implicit (String) | |
IL_000A newobj String..ctor | |
IL_000F pop | |
IL_0010 ret |
Author
guitarrapc
commented
Dec 7, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment