Re: function to check if a symbol in a library exists or not

  • From: Coda Highland <chighland@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 31 Jul 2012 07:03:34 -0700

On Tue, Jul 31, 2012 at 3:27 AM, Fjölnir Ásgeirsson
<fjolnir@xxxxxxxxxxxxx> wrote:
> Well no. It pcalls, and catches the error. That can't possibly be as fast as 
> just calling dlsym straight. (which is how you check for symbols at runtime 
> => I'm not sure what the issue is)

Mike Pall said just a few e-mails ago that pcall is extremely cheap,
and it's free if it gets JIT-compiled. Meanwhile, exposing dlsym or
GetProcAddress is essentially re-doing the work LuaJIT is already
doing internally.

Now that I understand what's going on, that check() function is doing
it exactly right, especially since he's storing the results instead of
calling it every time he needs to check.

/s/ Adam

Other related posts: