[erlang-questions] What is the fastest way to check if a function is defined in a module?
Tue Mar 6 16:40:42 CET 2018
On 6 Mar 2018, 16:36 +0100, Richard Carlsson <carlsson.richard@REDACTED>, wrote:
> is_exported(M, F, A) ->
> case erlang:module_loaded(M) of
> false -> code:ensure_loaded(M);
> true -> ok
> erlang:function_exported(M, F, A).
> (code:ensure_loaded() is slow compared to the fast call to erlang:module_loaded(), even if the module is already in memory).
I was recently wondering about this. Is there a reason code:ensure_loaded() does not short circuit using erlang:module_loaded()? It could probably even skip the request to the code server entirely in case the module is already loaded.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions