Skip to content

Commit 5c44cb6

Browse files
authored
Merge pull request erlang#10831 from josevalim/jv-cover-module-copy
Optimize cover operations to avoid bytecode copies
2 parents d2b8bb4 + 851eeb9 commit 5c44cb6

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

lib/tools/src/cover.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,7 +2165,7 @@ do_compile_beam2(Module,Beam,UserOptions,Forms0,MainFile,LocalOnly) ->
21652165
case code:load_binary(Module, ?TAG, Binary) of
21662166
{module, Module} ->
21672167
%% Store binary code so it can be loaded on remote nodes.
2168-
ets:insert(?BINARY_TABLE, {Module, Binary}),
2168+
ets:insert(?BINARY_TABLE, {Module, (not LocalOnly) andalso Binary}),
21692169
{ok, Module};
21702170
_Error ->
21712171
do_clear(Module),
@@ -2440,7 +2440,7 @@ delete_all_counters() ->
24402440
24412441
%% Collect data for all modules
24422442
collect(Nodes) ->
2443-
Modules = [Module || {Module,_} <- ets:tab2list(?BINARY_TABLE)],
2443+
Modules = [Module || [Module] <- ets:match(?BINARY_TABLE, {'$1', '_'})],
24442444
collect_modules(Modules, Nodes).
24452445
24462446
%% Collect data for a list of modules
@@ -2537,8 +2537,8 @@ analyse_list(Modules, Analysis, Level, State) ->
25372537
25382538
analyse_all(Analysis, Level, State) ->
25392539
collect(State#main_state.nodes),
2540-
All = ets:tab2list(?BINARY_TABLE),
2541-
Fun = fun({Module,_}) ->
2540+
All = ets:match(?BINARY_TABLE, {'$1', '_'}),
2541+
Fun = fun([Module]) ->
25422542
do_analyse(Module, Analysis, Level)
25432543
end,
25442544
{result, lists:flatten(pmap(Fun, All)), []}.

0 commit comments

Comments
 (0)