<div dir="ltr">I was actually considering submitting such a patch a while back, but one argument against making that short-cut could be that operations against the code server should be serialized. On the other hand I haven't yet come up with an example where the short-cut would make a difference that couldn't already happen due to processor scheduling.</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><br> /Richard</div></div>
<br><div class="gmail_quote">2018-03-06 16:40 GMT+01:00 Michał Muskała <span dir="ltr"><<a href="mailto:michal@muskala.eu" target="_blank">michal@muskala.eu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><span class="">
<div name="messageBodySection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif">On 6 Mar 2018, 16:36 +0100, Richard Carlsson <<a href="mailto:carlsson.richard@gmail.com" target="_blank">carlsson.richard@gmail.com</a>>, wrote:</div>
</span><div name="messageReplySection" style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif"><span class=""><br>
<blockquote type="cite" style="margin:5px 5px;padding-left:10px;border-left:thin solid #1abc9c">
<div dir="ltr">
<div><br></div>
<div>
<div>is_exported(M, F, A) -></div>
<div> case erlang:module_loaded(M) of<br></div>
<div> false -> code:ensure_loaded(M);</div>
<div> true -> ok</div>
<div> end,</div>
<div> erlang:function_exported(M, F, A).</div>
<div><br></div>
<div>(code:ensure_loaded() is slow compared to the fast call to erlang:module_loaded(), even if the module is already in memory).</div>
<div> </div>
</div>
</div>
</blockquote>
<br>
</span><div>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.</div><span class="HOEnZb"><font color="#888888">
<div><br></div>
<div>Michał.</div>
<div></div>
</font></span></div>
</div>
</blockquote></div><br></div>