From: Jaroslav Kysela Date: Tue, 3 Nov 2009 15:34:34 +0000 (+0100) Subject: Cache libasound.so access in snd_dlopen X-Git-Tag: v1.0.22~14 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=0bff86858030d4d19bbc39e50913853f963799af;p=alsa-lib.git Cache libasound.so access in snd_dlopen Speed up repeated calls to snd_dlopen by caching the path to libasound.so; this reduces the instructions executed by snd_device_name_hint by 40 percent. Signed-off-by: John Lindgren Signed-off-by: Jaroslav Kysela --- diff --git a/src/dlmisc.c b/src/dlmisc.c index c882cdcf..3cca0f08 100644 --- a/src/dlmisc.c +++ b/src/dlmisc.c @@ -54,9 +54,13 @@ void *snd_dlopen(const char *name, int mode) #else #ifdef HAVE_LIBDL if (name == NULL) { - Dl_info dlinfo; - if (dladdr(snd_dlopen, &dlinfo) > 0) - name = dlinfo.dli_fname; + static const char * self = NULL; + if (self == NULL) { + Dl_info dlinfo; + if (dladdr(snd_dlopen, &dlinfo) > 0) + self = dlinfo.dli_fname; + } + name = self; } #endif #endif