Skip to content
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

Merged
merged 2 commits into from Dec 26, 2018
Merged

Conversation

lahma
Copy link
Collaborator

@lahma lahma commented Dec 22, 2018

No description provided.

@@ -234,15 +235,15 @@ public static string ToBase(long n, int radix)
return "0";
}

var result = new StringBuilder();
var result = StringBuilderPool.GetInstance();
Copy link
Owner

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?

Copy link
Collaborator Author

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++)
Copy link
Owner

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?

Copy link
Collaborator Author

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.

@lahma
Copy link
Collaborator Author

lahma commented Dec 23, 2018

Rebased and cleaned StringBuilderPool, now using dispose pattern.

* change StringBuilderPool to be disposable
@sebastienros sebastienros merged commit f65d588 into sebastienros:dev Dec 26, 2018
@lahma lahma changed the title ES6 String Literals ES6 Template Strings Dec 26, 2018
@lahma lahma deleted the es6-literal-string branch December 27, 2018 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants