diff options
author | Björn Gustavsson <[email protected]> | 2015-04-17 11:43:20 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-04-22 10:14:55 +0200 |
commit | 84705583c517437f59e5b2b3833e1dc1a693830a (patch) | |
tree | 9617620162336cc4013f34a238bf019cc19a6c96 /lib/compiler/src/beam_utils.erl | |
parent | 37225949b6cf177934848fff21a1a551b7f6faee (diff) | |
download | otp-84705583c517437f59e5b2b3833e1dc1a693830a.tar.gz otp-84705583c517437f59e5b2b3833e1dc1a693830a.tar.bz2 otp-84705583c517437f59e5b2b3833e1dc1a693830a.zip |
beam_utils: Optimize index_labels_1/2
The execution time for beam_utils:index_labels_1/2 is among
the longest in the beam_bool, beam_bsm, beam_receive, and
beam_trim compiler passes. Therefore it is worthwhile to do
the minor optimization of replacing a call to lists:dropwhile/2
with a special-purpose drop_labels function.
Diffstat (limited to 'lib/compiler/src/beam_utils.erl')
-rw-r--r-- | lib/compiler/src/beam_utils.erl | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/compiler/src/beam_utils.erl b/lib/compiler/src/beam_utils.erl index 7704690f86..fd666be41e 100644 --- a/lib/compiler/src/beam_utils.erl +++ b/lib/compiler/src/beam_utils.erl @@ -612,13 +612,15 @@ is_reg_used_at_1(R, Lbl, St0) -> end. index_labels_1([{label,Lbl}|Is0], Acc) -> - Is = lists:dropwhile(fun({label,_}) -> true; - (_) -> false end, Is0), + Is = drop_labels(Is0), index_labels_1(Is0, [{Lbl,Is}|Acc]); index_labels_1([_|Is], Acc) -> index_labels_1(Is, Acc); index_labels_1([], Acc) -> gb_trees:from_orddict(sort(Acc)). +drop_labels([{label,_}|Is]) -> drop_labels(Is); +drop_labels(Is) -> Is. + %% Help functions for combine_heap_needs. combine_alloc_lists(Al1, Al2) -> |