diff options
author | Haitao Li <[email protected]> | 2011-07-27 09:43:49 +0800 |
---|---|---|
committer | Haitao Li <[email protected]> | 2011-07-27 09:43:49 +0800 |
commit | 76cd9849a1ff01e33441264108708cf7ad29f828 (patch) | |
tree | ceabecfdbb8c268f37f29a7f4f0579521615b11a | |
parent | a3d8134ffcb4ec7be60bdc896fb9be0928c2b1ff (diff) | |
download | otp-76cd9849a1ff01e33441264108708cf7ad29f828.tar.gz otp-76cd9849a1ff01e33441264108708cf7ad29f828.tar.bz2 otp-76cd9849a1ff01e33441264108708cf7ad29f828.zip |
ic: Improve ic_pragma performance by using ets:match
`ets:tab2list/1` followed by list comprehension is used in a few
places in module ic_pragma. This introduces significant performance
impact on large lists.
-rw-r--r-- | lib/ic/src/ic_pragma.erl | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/lib/ic/src/ic_pragma.erl b/lib/ic/src/ic_pragma.erl index 45cb64c9c8..6af1bbf26e 100644 --- a/lib/ic/src/ic_pragma.erl +++ b/lib/ic/src/ic_pragma.erl @@ -1600,9 +1600,8 @@ remove_inheriters(S,RS,InheriterList) -> [_OneOnly] -> ReducedInhList; _Other -> - EtsList = ets:tab2list(S), CleanList = - [X || X <- EtsList, element(1,X) == inherits], + ets:match(S, {inherits,'_','_'}), % CodeOptList = % [X || X <- EtsList, element(1,X) == codeopt], NoInheriters =remove_inheriters2(S,ReducedInhList,CleanList), @@ -1648,9 +1647,8 @@ remove_inh([X],[Y],List,EtsList) -> %%% from others in the list %%%---------------------------------------------- remove_inherited(S,InheriterList) -> - EtsList = ets:tab2list(S), CleanList = - [X || X <- EtsList, element(1,X) == inherits], + ets:match(S, {inherits, '_', '_'}), remove_inherited(S,InheriterList,CleanList). @@ -1694,11 +1692,8 @@ remove_inhed([X],[Y],List,EtsList) -> %% are inherited from scope in the list %%%---------------------------------------------- get_inherited(S,Scope,OpScopeList) -> - EtsList = ets:tab2list(S), - [[element(3,X)] || X <- EtsList, - element(1,X) == inherits, - element(2,X) == Scope, - member([element(3,X)],OpScopeList)]. + EtsList1 = ets:match(S, {inherits, Scope, '$1'}), + [X || X <- EtsList1, member(X, OpScopeList)]. @@ -1771,9 +1766,7 @@ inherits2(_X,Y,Z,EtsList) -> %% false otherwise %% is_inherited_by(Interface1,Interface2,PragmaTab) -> - FullList = ets:tab2list(PragmaTab), - InheritsList = - [X || X <- FullList, element(1,X) == inherits], + InheritsList = ets:match(PragmaTab, {inherits, '_', '_'}), inherits(Interface2,Interface1,InheritsList). |