- Notifications
You must be signed in to change notification settings - Fork748
Intern string#1254
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Intern string#1254
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
<#@ 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 getinternNames
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
conststrings="1";switch( case"1":// both "1" point to the same stringbreak;
- 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
.
Uh oh!
There was an error while loading.Please reload this page.
codecov-io commentedOct 22, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
|
Uh oh!
There was an error while loading.Please reload this page.
@amos402 did you have a chance to compare benchmarks on your branch with |
amos402 commentedNov 6, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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