quickjs-ng / quickjs

QuickJS, the Next Generation: a mighty JavaScript engine
https://quickjs-ng.github.io/quickjs/
MIT License
1.07k stars 94 forks source link

Improve BigInt hashing #35

Closed bnoordhuis closed 1 year ago

bnoordhuis commented 1 year ago

map_hash_key() currently doesn't know how to hash bigints, it always returns the same hash value.

Bad for performance, it turns amortized O(1) operations into O(n).

bnoordhuis commented 1 year ago

Note to my future self: the fix assumes bigints are always in most minimal form; e.g. 42 is stored as one word, not two. I think that's always the case and it's probably a bug if it isn't but that's where to start looking if something doesn't work right.