aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/src/code_server.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-02-06 07:43:43 +0100
committerBjörn Gustavsson <[email protected]>2016-02-25 14:53:10 +0100
commit54debd4a9ce3afb680738179d29bafb43e2cba3b (patch)
treeb00dcf98051e59d2837dfefa56ab3c8345ccb36f /lib/kernel/src/code_server.erl
parentb9869e4940c991783be56d12507f127c85b8bac4 (diff)
downloadotp-54debd4a9ce3afb680738179d29bafb43e2cba3b.tar.gz
otp-54debd4a9ce3afb680738179d29bafb43e2cba3b.tar.bz2
otp-54debd4a9ce3afb680738179d29bafb43e2cba3b.zip
Simplify and robustify code_server:all_loaded/1
The main ets table kept by code_server contains several pieces of information. Therefore, code_server:all_loaded/1 need to filter the information in the table. code_server:all_loaded/1 can be simplified if we use ets:select/2. Currently, the filtering is done by filtering away unwanted stuff ({sticky_dir,Mod} tuples). It is more robust to filter on the stuff that we want to keep ({Mod,Path} tuples, where Mod is an atom) in case that we'll add more auxiliary records to the table later.
Diffstat (limited to 'lib/kernel/src/code_server.erl')
-rw-r--r--lib/kernel/src/code_server.erl15
1 files changed, 3 insertions, 12 deletions
diff --git a/lib/kernel/src/code_server.erl b/lib/kernel/src/code_server.erl
index b52def8777..09cf27d655 100644
--- a/lib/kernel/src/code_server.erl
+++ b/lib/kernel/src/code_server.erl
@@ -28,6 +28,7 @@
]).
-include_lib("kernel/include/file.hrl").
+-include_lib("stdlib/include/ms_transform.hrl").
-import(lists, [foreach/2]).
@@ -1317,18 +1318,8 @@ finish_on_load_report(Mod, Term) ->
%% -------------------------------------------------------
all_loaded(Db) ->
- all_l(Db, ets:slot(Db, 0), 1, []).
-
-all_l(_Db, '$end_of_table', _, Acc) ->
- Acc;
-all_l(Db, ModInfo, N, Acc) ->
- NewAcc = strip_mod_info(ModInfo,Acc),
- all_l(Db, ets:slot(Db, N), N + 1, NewAcc).
-
-
-strip_mod_info([{{sticky,_},_}|T], Acc) -> strip_mod_info(T, Acc);
-strip_mod_info([H|T], Acc) -> strip_mod_info(T, [H|Acc]);
-strip_mod_info([], Acc) -> Acc.
+ Ms = ets:fun2ms(fun({M,_}=T) when is_atom(M) -> T end),
+ ets:select(Db, Ms).
-spec error_msg(io:format(), [term()]) -> 'ok'.
error_msg(Format, Args) ->