-
Notifications
You must be signed in to change notification settings - Fork 717
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
Intern string #1254
Intern string #1254
Conversation
<#@ template debug="true" hostSpecific="true" #> | ||
<#@ output extension=".cs" #> | ||
<# | ||
string[] internNames = new string[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use a template generator, when you can simply get internNames
from reflection? It looks like unnecessary complication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two reasons make this scenario happened.
- You need to make sure the string is a c# intern string too to make code like this work without extra checking
const string s = "1";
switch (
case "1":
// both "1" point to the same string
break;
- If you need (1), you have to make the
internNames
set on compile.
Of course, if you don't (1), internNames can just set by using reflection from readingPyIdentities
.
49e3340
to
021bf9f
Compare
021bf9f
to
955ef8d
Compare
Codecov Report
@@ Coverage Diff @@
## master #1254 +/- ##
=======================================
Coverage 86.25% 86.25%
=======================================
Files 1 1
Lines 291 291
=======================================
Hits 251 251
Misses 40 40
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
@amos402 did you have a chance to compare benchmarks on your branch with |
https://gist.github.com/amos402/8decd54dee57fe654e098bc0b15c061a CPU: Intel(R) Core(TM) i5-3470 CPU @ 3.20GHz
|
What does this implement/fix? Explain your changes.
Use the intern strings map to const strings instead of creating temporary strings everytimes.
Checklist
Check all those that are applicable and complete.
AUTHORS
CHANGELOG