Skip to content

Commit 2eed98d

Browse files
committed
Refactor: less concatenation for pattens.
1 parent 8250c3f commit 2eed98d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

analysis/src/ProcessCmt.ml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ let rec getModulePath mod_desc =
310310
let rec forItem ~env ~(exported : exported) item =
311311
match item.str_desc with
312312
| Tstr_value (_isRec, bindings) ->
313+
let declareds = ref [] in
313314
let rec handlePattern attributes pat =
314315
match pat.pat_desc with
315316
| Tpat_var (ident, name)
@@ -320,16 +321,16 @@ let rec forItem ~env ~(exported : exported) item =
320321
~extent:pat.pat_loc ~item attributes exported.values
321322
env.stamps.values
322323
in
323-
[{declared with item = MValue declared.item}]
324-
| Tpat_tuple pats -> pats |> List.map (handlePattern []) |> List.flatten
324+
declareds := {declared with item = MValue declared.item} :: !declareds
325+
| Tpat_tuple pats -> pats |> List.iter (fun p -> handlePattern [] p)
325326
| Tpat_record (items, _) ->
326-
items |> List.map (fun (_, _, p) -> handlePattern [] p) |> List.flatten
327-
| _ -> []
327+
items |> List.iter (fun (_, _, p) -> handlePattern [] p)
328+
| _ -> ()
328329
in
329-
List.map
330+
List.iter
330331
(fun {vb_pat; vb_attributes} -> handlePattern vb_attributes vb_pat)
331-
bindings
332-
|> List.flatten
332+
bindings;
333+
!declareds
333334
| Tstr_module
334335
{mb_id; mb_attributes; mb_loc; mb_name = name; mb_expr = {mod_desc}} ->
335336
let item = forModule env mod_desc name.txt in

0 commit comments

Comments
 (0)