Skip to content

Commit

Permalink
Micro-optimize Ident.compare
Browse files Browse the repository at this point in the history
This function is called a very large amount of times. Surprisingly, it
was calling the generic compare function.

This has a very small impact.

Co-authored-by: Guillaume Petiot <[email protected]>
  • Loading branch information
2 people authored and jonludlam committed Nov 7, 2023
1 parent 0b4a460 commit a88f7fe
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/xref2/ident.ml
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,7 @@ end

let hash : any -> int = Hashtbl.hash

let compare : any -> any -> int =
fun a b -> compare (int_of_any a) (int_of_any b)
let compare : any -> any -> int = fun a b -> int_of_any a - int_of_any b

module Maps = struct
module Module = Map.Make (struct
Expand Down

0 comments on commit a88f7fe

Please sign in to comment.