Skip to content

spread op shouldn't slice arguments #1015

@kaaaahhhhnnnn

Description

@kaaaahhhhnnnn

Using the spread op in an ES6 function:

function foo(...args){

compiles to something like:

function foo(args){
    args = [].slice.call(arguments, 0);
}

This leaks and prevents compiler optimization (There's about a 20x slowdown here). As much as I dislike code bloating, I believe it should compile to:

function foo(args){
    args=[];
    for(var i=0, l=arguments.length; i<l; i++){ args.push(arguments[i])); }
}

or similiar (obviously slightly different if the spread isn't the first argument).

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions