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

Could default exported function perform a tiny bit better? #28

Closed
realamirhe opened this issue Oct 5, 2020 · 3 comments
Closed

Could default exported function perform a tiny bit better? #28

realamirhe opened this issue Oct 5, 2020 · 3 comments

Comments

@realamirhe
Copy link

realamirhe commented Oct 5, 2020

export default function () {
- 	var i=0, tmp, x, str='';
+ 	var tmp, x, len=arguments.length, str='', i=0;
-	while (i < arguments.length) {
+	while (i < len) {
		if (tmp = arguments[i++]) {
			if (x = toVal(tmp)) {
				str && (str += ' ');
				str += x
			}
		}
	}
	return str;
}

Benchmark on only string concatenation shows an increase of about 1,000,000 operation/sec.
Note: I got benchmark results only in node, in a really inaccurate way. but theoretically, it must increase the performance.

@lukeed
Copy link
Owner

lukeed commented Oct 5, 2020

Hey, thanks!

This is already done in #26 – I haven't been able to setup a clean bench environment to test this out yet.
Caching a foo.length used to not matter, but it may very well matter once again.

It's on my TODO list to go through these PRs.

@hood
Copy link

hood commented Apr 17, 2022

Any news on this?

@lukeed
Copy link
Owner

lukeed commented Dec 29, 2023

This was addressed & merged in the linked PR. Thanks

@lukeed lukeed closed this as completed Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@lukeed @realamirhe @hood and others