Changeset [c3088e3f623c4b9ac09fa20475a0a657cb1290b7] by Arthur Schreiber

March 13th, 2010 @ 12:28 AM

Make Array#map, Array#some, Array#every and Array#filter implementations (almost) ES5 compliant and use native versions when possible, yielding huge performance improvements.

Prototype's implementations of these methods and the ES5 spec differ in the way a missing iterator function is handled:
Prototype uses Prototype.K as a default iterator, while ES5 specifies that a TypeError has to be thrown. Implementing the ES5 spec completely would break backward compatibility of Prototype and would force users to pass Prototype.K manually.

To keep backward compatibility when using browser native methods for Array#every and so on, these methods get wrapped. Some early performance benchmarks show that this wrapping has almost no performance impact.

This change should also fix #765, as the fallback implementations for the ES5 methods all can be called in a generic way.

Committed by Arthur Schreiber

  • M src/lang/array.js
  • M test/unit/array_test.js
New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Shared Ticket Bins