diff options
author | Björn Gustavsson <[email protected]> | 2015-11-10 15:41:59 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2015-11-11 06:00:38 +0100 |
commit | 9106490ce6fa3e21641ae0dc66f20b18f755fec3 (patch) | |
tree | 620987f25c1a99926e27bb8cab8fa8d9fb835c4e | |
parent | 80f9c7d0650330d53a3c457d85916447abe17194 (diff) | |
download | otp-9106490ce6fa3e21641ae0dc66f20b18f755fec3.tar.gz otp-9106490ce6fa3e21641ae0dc66f20b18f755fec3.tar.bz2 otp-9106490ce6fa3e21641ae0dc66f20b18f755fec3.zip |
beam_asm: Speed up assembly for modules with many exports
Eliminate searching in the list of exported functions in favor of
using a map. For modules with a huge number of exported functions
(such as NBAP-PDU-Contents in the asn1 test suite), that will mean a
significant speed-up.
-rw-r--r-- | lib/compiler/src/beam_asm.erl | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/compiler/src/beam_asm.erl b/lib/compiler/src/beam_asm.erl index a3201b0f4a..95be471de3 100644 --- a/lib/compiler/src/beam_asm.erl +++ b/lib/compiler/src/beam_asm.erl @@ -30,11 +30,12 @@ module(Code, Abst, SourceFile, Opts) -> {ok,assemble(Code, Abst, SourceFile, Opts)}. -assemble({Mod,Exp,Attr0,Asm0,NumLabels}, Abst, SourceFile, Opts) -> +assemble({Mod,Exp0,Attr0,Asm0,NumLabels}, Abst, SourceFile, Opts) -> {1,Dict0} = beam_dict:atom(Mod, beam_dict:new()), {0,Dict1} = beam_dict:fname(atom_to_list(Mod) ++ ".erl", Dict0), NumFuncs = length(Asm0), {Asm,Attr} = on_load(Asm0, Attr0), + Exp = cerl_sets:from_list(Exp0), {Code,Dict2} = assemble_1(Asm, Exp, Dict1, []), build_file(Code, Attr, Dict2, NumLabels, NumFuncs, Abst, SourceFile, Opts). @@ -61,7 +62,7 @@ insert_on_load_instruction(Is0, Entry) -> Bef ++ [El,on_load|Is]. assemble_1([{function,Name,Arity,Entry,Asm}|T], Exp, Dict0, Acc) -> - Dict1 = case member({Name,Arity}, Exp) of + Dict1 = case cerl_sets:is_element({Name,Arity}, Exp) of true -> beam_dict:export(Name, Arity, Entry, Dict0); false -> |