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
ES6 Template Strings #570
ES6 Template Strings #570
Conversation
2220195
to
4b97612
Compare
@@ -234,15 +235,15 @@ public static string ToBase(long n, int radix) | |||
return "0"; | |||
} | |||
|
|||
var result = new StringBuilder(); | |||
var result = StringBuilderPool.GetInstance(); |
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.
Would it make sense to have the pool return a disposable instance and release it on disposal?
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.
I can do that, checked perf and dispose changes my test case from 36.47 ns to 37.77 ns so it's negligble.
private JsString BuildString() | ||
{ | ||
var sb = StringBuilderPool.GetInstance(); | ||
for (var i = 0; i < _templateLiteralExpression.Quasis.Count; i++) |
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.
Is there a number of fragments under which a concat is faster than using a builder?
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.
Tried concatenation (+=) against builder and the are pretty much same speed-wise. After 2 placeholders string builder's allocation profile gets better.
* use StringBuilderPool
4b97612
to
fe04ae6
Compare
Rebased and cleaned StringBuilderPool, now using dispose pattern. |
* change StringBuilderPool to be disposable
fe04ae6
to
9bfa5f0
Compare
No description provided.