Replies: 3 comments 7 replies
-
This is not a language question. They're not hte same because they're not the same :) |
Beta Was this translation helpful? Give feedback.
3 replies
-
JIT optimization questions are for dotnet/runtime. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Use reflection to change the value of |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
For the longest time (probably since C# 1.1 😄) I thought that
""
andstring.Empty
were compiled identically by C#.And I just noticed that it's not the case!
C# compiles them quite literally to
ldstr
andldsfld
.Then the JIT performs some inlining magic but the result is still not quite the same:
string.Empty
is inlined into a constantmov eax, 0x9ef0004
.""
involves one memory accessmov eax, [0x5584684]
Ok this is a tiny difference that's probably never gonna be noticeable in a real life benchmark.
On the other hand this is a very low hanging fruit, so why not?
Beta Was this translation helpful? Give feedback.
All reactions