Closed Bug 698900 Opened 13 years ago Closed 4 months ago

Implement Array.prototype.* methods with unfixed number of parameters with rest parameters

Categories

(Core :: JavaScript Engine, enhancement)

enhancement

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: bruant.d, Unassigned)

References

Details

It seems (https://mail.mozilla.org/pipermail/es-discuss/2011-July/016124.html) that JS stack suffers when doing something like Array.prototype.push.apply(a1, a2) if a2 is to big of an array. One idea would to stop thinking as Array.prototype.push as a method with a lot of arguments, but rather think it as Array.prototype.push(...items) (as per "rest parameters"). For any number of elements, there would only be one element in the stack.
Depends on: harmony:restparams
Assignee: general → nobody
Severity: normal → S3

It's unclear what the actual concrete concern is here, and it's been 13 years.

Status: NEW → RESOLVED
Closed: 4 months ago
Resolution: --- → INCOMPLETE

Reading between the lines, I suspect that the reporter had learned that fn.apply(..., arr) will push every element of arr to the stack (potentially using a lot of stack space for large arrays) and wanted to suggest an alternative. However, the alternative has the same problem: spread calls have the same behaviour as apply, and in fact share a bunch of code under the covers.

You need to log in before you can comment on or make changes to this bug.