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
Julow and gpetiot committed Oct 9, 2023
1 parent 9e32d6e commit 838681e
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 @@ -363,8 +363,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 838681e

Please sign in to comment.