Skip to content

Commit 5ebcd50

Browse files
committed
optimization
1 parent 7c8a1fb commit 5ebcd50

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

lib/kernel/match/match_context.ml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ let update_match f m =
3535
{ m with range; environment }
3636

3737
let convert_offset ~fast ~source match_ =
38+
let index =
39+
if fast then
40+
Offset.index ~source
41+
else
42+
Offset.empty
43+
in
3844
let f offset =
39-
let index =
40-
if fast then
41-
Offset.index ~source
42-
else
43-
Offset.empty
44-
in
4545
if fast then
4646
Offset.convert_fast ~offset index
4747
else

lib/kernel/matchers/matcher_engine.ml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,8 +829,7 @@ module Make (Language : Types.Language.S) (Meta : Metasyntax.S) (Ext : External.
829829
let prefix = prefix >>= fun s -> r acc (String s) in
830830
let first_match_attempt = choice [ match_one; prefix ] in
831831
(* consumes a character in prefix if no match *)
832-
let matches = many first_match_attempt *> end_of_input in
833-
matches >>= fun _result -> r acc Unit)
832+
skip_many first_match_attempt *> end_of_input >>= fun () -> r acc Unit)
834833

835834
let to_template template rule =
836835
match parse_string ~consume:All (general_parser_generator rule) template with

lib/kernel/vendored/vangstrom/lib/vangstrom.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,10 @@ let sep_by s p =
531531

532532
let skip_many p =
533533
fix (fun m ->
534-
(p *> m) <|> return ())
534+
((p >>| fun _ -> true) <|> return false) >>= function
535+
| true -> m
536+
| false -> return ()
537+
)
535538

536539
let skip_many1 p =
537540
p *> skip_many p

0 commit comments

Comments
 (0)