Skip to content

Commit e1c2146

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 612b360 commit e1c2146

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
@@ -300,17 +300,17 @@ module VdNode = struct
300300
update loc1 (opts, Some loc2);
301301
end
302302

303-
303+
(* find the loc of the function declaring the nth occurence of the label *)
304304
let find loc lab occur =
305305
let met = LocHash.create 8 in
306306
let rec loop loc lab occur =
307307
let count =
308308
if is_end loc then 0
309309
else List.filter (( = ) lab) (get_opts loc) |> List.length
310310
in
311-
if is_end loc || LocHash.mem met loc || count >= !occur then loc
312-
else begin
313-
occur := !occur - count;
311+
if is_end loc || LocHash.mem met loc || count >= occur then loc
312+
else (
313+
let occur = occur - count in
314314
LocHash.replace met loc ();
315315
match get_next loc with
316316
| Some next -> loop (func next) lab occur
@@ -320,7 +320,7 @@ module VdNode = struct
320320
^ (string_of_int loc.Lexing.pos_lnum)
321321
in
322322
failwith (loc ^ ": optional argument `" ^ lab ^ "' unlinked")
323-
end
323+
)
324324
in loop (func loc) lab occur
325325

326326
let eof () =

0 commit comments

Comments
 (0)