js-on-sx: bail out of array set/length at 2^32-1 instead of padding
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
arr[4294967295] = 'x' and arr.length = 4294967295 were padding the SX list with js-undefined for ~4 billion entries — instant timeout. Per ES spec, indices >= 2^32-1 aren't array indices anyway (regular properties, which we can't store on lists). Added (>= i 4294967295) bail clauses to js-list-set! and the length setter. built-ins/Array: 21/45 → 23/45 (5 timeouts → 2). conformance.sh: 148/148.
This commit is contained in:
@@ -2866,6 +2866,7 @@
|
||||
((i (js-num-to-int key)) (n (len lst)))
|
||||
(cond
|
||||
((< i 0) nil)
|
||||
((>= i 4294967295) nil)
|
||||
((< i n) (set-nth! lst i val))
|
||||
((= i n) (append! lst val))
|
||||
(else (do (js-pad-list! lst n i) (append! lst val))))))
|
||||
@@ -2876,6 +2877,7 @@
|
||||
((target (js-num-to-int (js-to-number val))) (n (len lst)))
|
||||
(cond
|
||||
((< target 0) nil)
|
||||
((>= target 4294967295) nil)
|
||||
((> target n) (js-pad-list! lst n target))
|
||||
(else nil))))
|
||||
(else nil))))
|
||||
|
||||
Reference in New Issue
Block a user