aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2018-03-20 10:39:54 +0100
committerGitHub <[email protected]>2018-03-20 10:39:54 +0100
commit01460976cfa3222f618ac494f462eccd0ba9a1c8 (patch)
tree791cb8109d225afb03378938375a2e0a9f48f490 /lib/kernel
parentafef67efa388512ff5c3023bb9f3401bb7e7885b (diff)
parent3e0cecc541fc9cd85b4c5878e58a7ec4a3142368 (diff)
downloadotp-01460976cfa3222f618ac494f462eccd0ba9a1c8.tar.gz
otp-01460976cfa3222f618ac494f462eccd0ba9a1c8.tar.bz2
otp-01460976cfa3222f618ac494f462eccd0ba9a1c8.zip
Merge pull request #1742 from michalmuskala/code-ensure-loaded
Short-circuit code:ensure_loaded for already-loaded modules
Diffstat (limited to 'lib/kernel')
-rw-r--r--lib/kernel/src/code.erl7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/kernel/src/code.erl b/lib/kernel/src/code.erl
index 9969021a6c..f143a49d2f 100644
--- a/lib/kernel/src/code.erl
+++ b/lib/kernel/src/code.erl
@@ -149,8 +149,11 @@ load_file(Mod) when is_atom(Mod) ->
-spec ensure_loaded(Module) -> {module, Module} | {error, What} when
Module :: module(),
What :: embedded | badfile | nofile | on_load_failure.
-ensure_loaded(Mod) when is_atom(Mod) ->
- call({ensure_loaded,Mod}).
+ensure_loaded(Mod) when is_atom(Mod) ->
+ case erlang:module_loaded(Mod) of
+ true -> {module, Mod};
+ false -> call({ensure_loaded,Mod})
+ end.
%% XXX File as an atom is allowed only for backwards compatibility.
-spec load_abs(Filename) -> load_ret() when