aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-04-18 06:58:08 +0200
committerBjörn Gustavsson <[email protected]>2015-04-22 10:14:55 +0200
commit08708c8327a0e75190a738ceae5080480e2c1e4f (patch)
tree17c5f23d11884621724f21dca727721d9ff83cf9
parentf5298679670260be1ea2caba212d20c528701455 (diff)
downloadotp-08708c8327a0e75190a738ceae5080480e2c1e4f.tar.gz
otp-08708c8327a0e75190a738ceae5080480e2c1e4f.tar.bz2
otp-08708c8327a0e75190a738ceae5080480e2c1e4f.zip
beam_jump: Replace use of lists:dropwhile/2 with a custom function
The use of lists:dropwhile/2 is noticeable in the eprof results.
-rw-r--r--lib/compiler/src/beam_jump.erl11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/compiler/src/beam_jump.erl b/lib/compiler/src/beam_jump.erl
index ba71d4efae..52b6464c7f 100644
--- a/lib/compiler/src/beam_jump.erl
+++ b/lib/compiler/src/beam_jump.erl
@@ -127,7 +127,7 @@
%%% on the program state.
%%%
--import(lists, [reverse/1,reverse/2,foldl/3,dropwhile/2]).
+-import(lists, [reverse/1,reverse/2,foldl/3]).
module({Mod,Exp,Attr,Fs0,Lc}, _Opt) ->
Fs = [function(F) || F <- Fs0],
@@ -509,10 +509,7 @@ rem_unused([{label,Lbl}=I|Is0], Used, [Prev|_]=Acc) ->
case gb_sets:is_member(Lbl, Used) of
false ->
Is = case is_unreachable_after(Prev) of
- true ->
- dropwhile(fun({label,_}) -> false;
- (_) -> true
- end, Is0);
+ true -> drop_upto_label(Is0);
false -> Is0
end,
rem_unused(Is, Used, Acc);
@@ -533,6 +530,10 @@ initial_labels([{label,Lbl}|Is], Acc) ->
initial_labels([{func_info,_,_,_},{label,Lbl}|_], Acc) ->
gb_sets:from_list([Lbl|Acc]).
+drop_upto_label([{label,_}|_]=Is) -> Is;
+drop_upto_label([_|Is]) -> drop_upto_label(Is);
+drop_upto_label([]) -> [].
+
%% ulbl(Instruction, UsedGbSet) -> UsedGbSet'
%% Update the gb_set UsedGbSet with any function-local labels
%% (i.e. not with labels in call instructions) referenced by