Skip to content

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

@JosephLenton

Description

@JosephLenton

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).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions