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

StringBuilder performance #637

Closed
neuronsupport opened this issue Oct 16, 2020 · 3 comments
Closed

StringBuilder performance #637

neuronsupport opened this issue Oct 16, 2020 · 3 comments

Comments

@neuronsupport
Copy link

neuronsupport commented Oct 16, 2020

The code generated for StringBuilder append makes use of concat method which is a very slow operation. It would make it more agile if we use '+' operator for simple appends which is much faster than concat.

	StringBuilder a=new StringBuilder();
	a.append("Hi");
	a.append(" there");

from

      var a = { str: "", toString: function () { return this.str; } };
                /* append */ (function (sb) { sb.str = sb.str.concat("Hi"); return sb; })(a);
                /* append */ (function (sb) { sb.str = sb.str.concat(" there"); return sb; })(a);

to

      var a = { str: "", toString: function () { return this.str; } };
                /* append */ (function (sb) { sb.str += "Hi"; return sb; })(a);
                /* append */ (function (sb) { sb.str += " there"; return sb; })(a);

@lgrignon
Copy link
Collaborator

Hello @norzak
Thanks for your suggestions. Sounds like a good idea indeed given this.
Would you like to try to add this improvment and PR? I think you will find this in RemoveJavaDependenciesAdapter

@neuronsupport
Copy link
Author

neuronsupport commented Oct 17, 2020

pull request #638

@lgrignon
Copy link
Collaborator

Perfect, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants