Bug 1260673 - Stop using _DefineDataProperty in MoveHoles; r=jorendorff

_DefineDataProperty was used to ensure that modifying Array's setter wouldn't
impact sorting, however, this is both not necessary and against the spec.

--HG--
extra : rebase_source : f7d1301abf3207e2091f4c1e3b7e3949c0961ec8
This commit is contained in:
Morgan Phillips 2016-03-31 14:44:12 -07:00
parent c6555da9ca
commit c5fa3b7151
2 changed files with 1 additions and 15 deletions

View File

@ -220,7 +220,7 @@ function Merge(list, start, mid, end, lBuffer, rBuffer, comparefn) {
// dense array, filling remaining slots with holes.
function MoveHoles(sparse, sparseLen, dense, denseLen) {
for (var i = 0; i < denseLen; i++)
_DefineDataProperty(sparse, i, dense[i]);
sparse[i] = dense[i];
for (var j = denseLen; j < sparseLen; j++)
delete sparse[j];
}

View File

@ -54,19 +54,5 @@ assertDeepEq(oneHole[0], {size: 27});
assertEq(oneHole.length, 2600);
assertEq(denseCount(oneHole), 1);
// Ensure that the array setter is touch touched during sorting.
Object.defineProperty(Array.prototype, "0", {
set: (value) => {throw "Illegally touched the array's setter!"},
configurable: true
});
assertThrows(() => {o[1] = 11;});
let o = [,,,,,,,,,,,,,,,,,,,,{size: 1},{size: 2}];
o.sort((a, b) => {+a.size - +b.size});
delete Array.prototype["0"];
if (typeof reportCompare === 'function')
reportCompare(0, 0);