Skip to content

Commit c70f140

Browse files
committed
[src][deadCommon] remove unnecessary ref
The `find` function was expecting a `ref` for the `occur` parameter although it is always passed (updated) as argument to its inner `loop` function.
1 parent f0ad76b commit c70f140

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/deadArg.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ let register_use label expr builddir loc last_loc count_tbl =
4343
else expr.exp_loc.Location.loc_start
4444
in
4545
if check_underscore label then
46-
let loc = VdNode.find loc label (ref count) in
46+
let loc = VdNode.find loc label count in
4747
if not (Hashtbl.mem met (last_loc, loc, label)) then (
4848
Hashtbl.add met (last_loc, loc, label) ();
4949
let opt_arg_use = {

src/deadCommon.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,17 +298,17 @@ module VdNode = struct
298298
update loc1 (opts, Some loc2);
299299
end
300300

301-
301+
(* find the loc of the function declaring the nth occurence of the label *)
302302
let find loc lab occur =
303303
let met = LocHash.create 8 in
304304
let rec loop loc lab occur =
305305
let count =
306306
if is_end loc then 0
307307
else List.filter (( = ) lab) (get_opts loc) |> List.length
308308
in
309-
if is_end loc || LocHash.mem met loc || count >= !occur then loc
310-
else begin
311-
occur := !occur - count;
309+
if is_end loc || LocHash.mem met loc || count >= occur then loc
310+
else (
311+
let occur = occur - count in
312312
LocHash.replace met loc ();
313313
match get_next loc with
314314
| Some next -> loop (func next) lab occur
@@ -318,7 +318,7 @@ module VdNode = struct
318318
^ (string_of_int loc.Lexing.pos_lnum)
319319
in
320320
failwith (loc ^ ": optional argument `" ^ lab ^ "' unlinked")
321-
end
321+
)
322322
in loop (func loc) lab occur
323323

324324
let eof () =

0 commit comments

Comments
 (0)