Skip to content

Commit

Permalink
Use compare instead of introducing equal
Browse files Browse the repository at this point in the history
  • Loading branch information
xvw committed Feb 27, 2024
1 parent bda6f34 commit c2be4f1
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 10 deletions.
2 changes: 1 addition & 1 deletion src/analysis/destruct.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 0 additions & 6 deletions src/ocaml/parsing/location_aux.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions src/ocaml/parsing/location_aux.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c2be4f1

Please sign in to comment.