I’m using the module Hashtbl of Core to create a hash table whose key is of the type
Llvm.llvalue. Here is the function
let create ?growth_allowed ?size m = create ~hashable:(Hashable.of_key m) ?growth_allowed ?size () ;;
In my code, I need to define a wrapping module
Llvm.llvalue, and call
Hashtbl.create (module Llvalue). The module
Llvalue is like follow:
module Llvalue = struct type t = Llvm.llvalue let hash = Hashtbl.hash let sexp_of_t = LL.string_of_llvalue let compare = ??? (* how should I define `compare`? *) end
Since Llvm does not provide a built-in
compare function, how should I define it to optimize the performance of the hash table?
My simple solution is to convert
Llvm.llvalue to strings, and compare the output strings, but I think it might not be the best solution.
Thanks for spending your time to read my question!