diff options
author | Björn Gustavsson <[email protected]> | 2015-04-18 06:58:08 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-04-22 10:14:55 +0200 |
commit | 08708c8327a0e75190a738ceae5080480e2c1e4f (patch) | |
tree | 17c5f23d11884621724f21dca727721d9ff83cf9 /lib/compiler/src/beam_jump.erl | |
parent | f5298679670260be1ea2caba212d20c528701455 (diff) | |
download | otp-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.
Diffstat (limited to 'lib/compiler/src/beam_jump.erl')
-rw-r--r-- | lib/compiler/src/beam_jump.erl | 11 |
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 |