Skip to content

Commit a88f7fe

Browse files
Julowgpetiot
authored andcommitted
Micro-optimize Ident.compare
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]>
1 parent 0b4a460 commit a88f7fe

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/xref2/ident.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,7 @@ end
367367

368368
let hash : any -> int = Hashtbl.hash
369369

370-
let compare : any -> any -> int =
371-
fun a b -> compare (int_of_any a) (int_of_any b)
370+
let compare : any -> any -> int = fun a b -> int_of_any a - int_of_any b
372371

373372
module Maps = struct
374373
module Module = Map.Make (struct

0 commit comments

Comments
 (0)