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

add 'valueOf' optimizations for calling methods on literals #12

Open
JosephLenton opened this issue Jun 13, 2014 · 0 comments
Open

add 'valueOf' optimizations for calling methods on literals #12

JosephLenton opened this issue Jun 13, 2014 · 0 comments

Comments

@JosephLenton
Copy link
Member

When you extend Number, String, or Boolean, use 'valueOf' inside of the class when we call an in-built method. This gives a huge speedup.

The speedup is only there for the in-built methods, not for the ones we add on.

For example this is good ...
// substring is provided
this.valueOf().substring( 1 );

this is bad ...

// this substring was added by us, don't use valueOf here
this.valueOf()._quby_substring( 1 );

this is also bad ...

// don't use valueOf for comparisons, doesn't work
this.valueOf() === otherString ;

As of writing, this optimization works cross browser (but only a speedup of around 5% in IE and FF, Chrome it can double or triple the speed).

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

1 participant