ruma / js_int

JavaScript-interoperable integer types for Rust
MIT License
16 stars 8 forks source link

Can Hash implementation be improved? #2

Open jplatte opened 5 years ago

jplatte commented 5 years ago

Title should be self-explanatory.

jplatte commented 5 years ago

I had a look at the hashing interface, which I had never done before. We theoretically have 54 bits of information in Int and 53 bits in UInt. Both could be encoded in 7 bytes to give to the hasher instead of using the u64 value we currently use. After having thought about it, this only makes sense to me if we store our types in 7-byte form as well though. I personally don't see a large benefit in the saved byte per stored Int / UInt, but it would be a fun project. I'll create a new issue for it.