-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
string interpolation simple cases are not optimized (such as: string s1 = $"hello") #76
Comments
All this already implemented in |
Thanks you right, I chcked this in oficial CTP5 release. |
What if the current culture has a formater that does something with |
And how common is it in performance-critical situations to be doing string formatting with constant null values? Even if it could be optimized, seems extremely corner-case, or am I missing something? |
Is there a valid reason to ever write something like |
Perhaps when an interpolated variable refers to var text = $"hello{world}"; |
Why was
into
If any of the arg holes have alignment or format args then make the target |
Like I said before on this issue, my current culture might have custom formatting for that. The predictable way is to always be a call |
I cannot reproduce this "bug". I see the code in the compiler to perform this optimization and your test appears to show it working properly: |
string s1 = $"hello";
emitsstring s1= string.Format("hello", new object[0]);
instead of simple:
s1 = "hello";
also consider to optimize cases such as:
$"hello" + $" " + $"world"
to constant expression evaluation (or at least one string.Format() call, not 3 in this case)The text was updated successfully, but these errors were encountered: