goto exception;
}
- if (njs_fast_path(fast_path && njs_is_fast_array(this))) {
+ if (njs_fast_path(fast_path
+ && njs_is_fast_array(this)
+ && (njs_array(this)->length == length)))
+ {
array = njs_array(this);
start = array->start;
} else {
for (i = 0; i < len; i++) {
- if (slots[i].pos != i) {
- ret = njs_value_property_i64_set(vm, this, i, &slots[i].value);
- if (njs_slow_path(ret == NJS_ERROR)) {
- goto exception;
- }
+ ret = njs_value_property_i64_set(vm, this, i, &slots[i].value);
+ if (njs_slow_path(ret == NJS_ERROR)) {
+ goto exception;
}
}
{ njs_str("var a = [1,2]; a.sort(() => {a.length = 65535}); a.length"),
njs_str("65535") },
+ { njs_str("var a = [];"
+ "var shift = true;"
+ "for (let i = 0; i < 64; i++) {"
+ " a[i] = { toString() {"
+ " if (shift) { a.shift() };"
+ " return (63 - i).toString().padStart(2, '0');"
+ " }"
+ " };"
+ "}"
+ "a.sort();"
+ "shift = false;"
+ "[a.length, a[0].toString(), a[63].toString()]"),
+ njs_str("64,00,63") },
+
+ { njs_str("var a = [];"
+ "var shift = true;"
+ "for (let i = 0; i < 64; i++) {"
+ " a[i] = { toString() {"
+ " if (shift) { a.shift() };"
+ " return (i).toString().padStart(2, '0');"
+ " }"
+ " };"
+ "}"
+ "a.sort();"
+ "shift = false;"
+ "[a.length, a[0].toString(), a[63].toString()]"),
+ njs_str("64,00,63") },
+
/*
Array.prototype.keys()
Array.prototype.values()