hmap icon indicating copy to clipboard operation
hmap copied to clipboard

Reduce allocations using unique identifiers of keys as keys in the map

Open Armael opened this issue 2 years ago • 2 comments

Following the recent inclusion in the stdlib (as part of the new Type module) of Type.Id.uid, it looks like we can always compute a unique integer for type ids. This PR proposes to use this function to: 1) avoid computing uids separately and storing them along type ids; 2) index the underlying map with uids instead of indexing it using keys (that then need to be boxed). I think this should avoid the allocations mentioned in issue #2, although using a different approach than what is suggested there?

Armael avatar Jun 02 '23 20:06 Armael

Why not. Did you just check if the curent lower bound on OCaml needs updating (4.02) ?

dbuenzli avatar Jun 02 '23 21:06 dbuenzli

Ah, I had not. It looks like the Obj.Extension_constructor module was added in 4.08, so I guess we would now require OCaml >= 4.08.

Armael avatar Jun 02 '23 22:06 Armael