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 3caee43
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 17 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
7 changes: 0 additions & 7 deletions src/utils/std.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3caee43

Please sign in to comment.