From 3caee430b6f826da8012d37efbdbbdd9a89ffb2c Mon Sep 17 00:00:00 2001 From: xvw Date: Tue, 27 Feb 2024 18:12:26 +0100 Subject: [PATCH] Use `compare` instead of introducing `equal` --- src/analysis/destruct.ml | 2 +- src/ocaml/parsing/location_aux.ml | 6 ------ src/ocaml/parsing/location_aux.mli | 3 --- src/utils/std.ml | 7 ------- 4 files changed, 1 insertion(+), 17 deletions(-) diff --git a/src/analysis/destruct.ml b/src/analysis/destruct.ml index 9b46cd023b..a07b2770ce 100644 --- a/src/analysis/destruct.ml +++ b/src/analysis/destruct.ml @@ -489,7 +489,7 @@ let find_field_name_for_punning_field patt = function List.find_opt ~f:(fun (_, _, opat) -> let ppat_loc = patt.Typedtree.pat_loc and opat_loc = opat.Typedtree.pat_loc in - Location_aux.equal ppat_loc opat_loc + Int.equal (Location_aux.compare ppat_loc opat_loc) 0 ) fields |> Option.map ~f:(fun (_, label, _) -> label) | _ -> None diff --git a/src/ocaml/parsing/location_aux.ml b/src/ocaml/parsing/location_aux.ml index 7ee1b09ff9..966ebdd3f7 100644 --- a/src/ocaml/parsing/location_aux.ml +++ b/src/ocaml/parsing/location_aux.ml @@ -38,12 +38,6 @@ let compare (l1: t) (l2: t) = | 0 -> Lexing.compare_pos l1.loc_end l2.loc_end | _ -> assert false -let equal - { loc_start = start_a; loc_end = end_a; loc_ghost = ghost_a } - { loc_start = start_b; loc_end = end_b; loc_ghost = ghost_b } = - Lexing.equal_position start_a start_b && Lexing.equal_position end_a end_b && - Bool.equal ghost_a ghost_b - let compare_pos pos loc = if Lexing.compare_pos pos loc.Location.loc_start < 0 then -1 diff --git a/src/ocaml/parsing/location_aux.mli b/src/ocaml/parsing/location_aux.mli index 7128ac44b7..7d99d36a05 100644 --- a/src/ocaml/parsing/location_aux.mli +++ b/src/ocaml/parsing/location_aux.mli @@ -35,9 +35,6 @@ val compare : t -> t -> int val compare_pos: Lexing.position -> t -> int -(** [equal l1 l2] equality between location *) -val equal : t -> t -> bool - (** Return the smallest location covered by both arguments, ghost if both are ghosts *) val union : t -> t -> t diff --git a/src/utils/std.ml b/src/utils/std.ml index 65f721ac48..433e1b9527 100644 --- a/src/utils/std.ml +++ b/src/utils/std.ml @@ -549,13 +549,6 @@ module Lexing = struct include (Lexing : module type of struct include Lexing end with type position := position) - - let equal_position - { pos_fname = fname_a; pos_lnum = lnum_a; pos_bol = bol_a; pos_cnum = cnum_a } - { pos_fname = fname_b; pos_lnum = lnum_b; pos_bol = bol_b; pos_cnum = cnum_b } = - String.equal fname_a fname_b && Int.equal lnum_a lnum_b && - Int.equal bol_a bol_b && Int.equal cnum_a cnum_b - let move buf p = buf.lex_abs_pos <- (p.pos_cnum - buf.lex_curr_pos); buf.lex_curr_p <- p