Skip to content

Commit 08708c8

Browse files
committed
beam_jump: Replace use of lists:dropwhile/2 with a custom function
The use of lists:dropwhile/2 is noticeable in the eprof results.
1 parent f529867 commit 08708c8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/compiler/src/beam_jump.erl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@
127127
%%% on the program state.
128128
%%%
129129

130-
-import(lists, [reverse/1,reverse/2,foldl/3,dropwhile/2]).
130+
-import(lists, [reverse/1,reverse/2,foldl/3]).
131131

132132
module({Mod,Exp,Attr,Fs0,Lc}, _Opt) ->
133133
Fs = [function(F) || F <- Fs0],
@@ -509,10 +509,7 @@ rem_unused([{label,Lbl}=I|Is0], Used, [Prev|_]=Acc) ->
509509
case gb_sets:is_member(Lbl, Used) of
510510
false ->
511511
Is = case is_unreachable_after(Prev) of
512-
true ->
513-
dropwhile(fun({label,_}) -> false;
514-
(_) -> true
515-
end, Is0);
512+
true -> drop_upto_label(Is0);
516513
false -> Is0
517514
end,
518515
rem_unused(Is, Used, Acc);
@@ -533,6 +530,10 @@ initial_labels([{label,Lbl}|Is], Acc) ->
533530
initial_labels([{func_info,_,_,_},{label,Lbl}|_], Acc) ->
534531
gb_sets:from_list([Lbl|Acc]).
535532

533+
drop_upto_label([{label,_}|_]=Is) -> Is;
534+
drop_upto_label([_|Is]) -> drop_upto_label(Is);
535+
drop_upto_label([]) -> [].
536+
536537
%% ulbl(Instruction, UsedGbSet) -> UsedGbSet'
537538
%% Update the gb_set UsedGbSet with any function-local labels
538539
%% (i.e. not with labels in call instructions) referenced by

0 commit comments

Comments
 (0)