Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix infinite loop in rindexes with maxless data
Verify that index is not undefined in isValidIndex() Fixes a bug introduced in c29079d, when support for non-preallocated data bound by ttl and/or maxSize was added. When the pointer array is a `number[]` instead of a `UintArray`, unset values will be `undefined` rather than `0`, resulting in the situation where `index === this.keyMap.get(this.keyList[index])` is not a valid test for index validity, since it can be `undefined` rather than always being guaranteed to be a number. Another way to fix this would be ensure that a previously unused spot in the array is initialized to `0` when pointers are initialized. However, in performance critical cases, every set and get matters, and relying on the initialized state of a UintArray saves that check in several hot paths. On the other hand, the test for `index === undefined` only has to happen during iteration, which is much less likely to be performance critical. Fix: #278
- Loading branch information