Skip to content

Commit

Permalink
simplify hash to just use low 28 bits
Browse files Browse the repository at this point in the history
  • Loading branch information
crusso committed Feb 16, 2024
1 parent d15162e commit f6b671d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion collections/motoko/src/ZhenyaHashmap.mo
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import Prim "mo:prim";
actor {
stable let profiling = Profiling.init();

let hash : HashMap.HashUtils<Nat64> = HashMap.n64hash;
let public func hashNat64(key: Nat64): Nat32 {
Prim.nat64ToNat32(key & 0x0fff_ffff);
};

let hash : HashMap.HashUtils<Nat64> = (hashNat64, func (x,y) = x == y);

stable var map = HashMap.new<Nat64, Nat64>();
let rand = Random.new(null, 42);

Expand Down

0 comments on commit f6b671d

Please sign in to comment.