aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-11-10 16:27:53 +0100
committerBjörn Gustavsson <[email protected]>2015-11-11 06:00:45 +0100
commitf9a3728566668a6ad54067fe347ab9055d351b7a (patch)
tree1ec98c6e691435c11e0d5556385ac2a65e1f2e90 /lib/compiler/src
parent30b70dbe78b8acc7a5450518cf89d9749ce6730d (diff)
downloadotp-f9a3728566668a6ad54067fe347ab9055d351b7a.tar.gz
otp-f9a3728566668a6ad54067fe347ab9055d351b7a.tar.bz2
otp-f9a3728566668a6ad54067fe347ab9055d351b7a.zip
v3_kernel: Speed up compilation of modules with many funs
Using a map to store the number of free variables for funs instead of an orddict will speed up the v3_kernel pass for modules with a huge number of funs (such as NBAP-PDU-Contents in the asn1 test suite).
Diffstat (limited to 'lib/compiler/src')
-rw-r--r--lib/compiler/src/v3_kernel.erl17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/compiler/src/v3_kernel.erl b/lib/compiler/src/v3_kernel.erl
index 7ee564683b..011748df3a 100644
--- a/lib/compiler/src/v3_kernel.erl
+++ b/lib/compiler/src/v3_kernel.erl
@@ -117,7 +117,7 @@ copy_anno(Kdst, Ksrc) ->
fcount=0, %Fun counter
ds=cerl_sets:new() :: cerl_sets:set(), %Defined variables
funs=[], %Fun functions
- free=[], %Free variables
+ free=#{}, %Free variables
ws=[] :: [warning()], %Warnings.
guard_refc=0}). %> 0 means in guard
@@ -1837,14 +1837,17 @@ handle_reuse_anno_1(V, _St) -> V.
%% get_free(Name, Arity, State) -> [Free].
%% store_free(Name, Arity, [Free], State) -> State.
-get_free(F, A, St) ->
- case orddict:find({F,A}, St#kern.free) of
- {ok,Val} -> Val;
- error -> []
+get_free(F, A, #kern{free=FreeMap}) ->
+ Key = {F,A},
+ case FreeMap of
+ #{Key:=Val} -> Val;
+ _ -> []
end.
-store_free(F, A, Free, St) ->
- St#kern{free=orddict:store({F,A}, Free, St#kern.free)}.
+store_free(F, A, Free, #kern{free=FreeMap0}=St) ->
+ Key = {F,A},
+ FreeMap = FreeMap0#{Key=>Free},
+ St#kern{free=FreeMap}.
break_rets({break,Rs}) -> Rs;
break_rets(return) -> [].