]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Cache libasound.so access in snd_dlopen
authorJaroslav Kysela <perex@perex.cz>
Tue, 3 Nov 2009 15:34:34 +0000 (16:34 +0100)
committerJaroslav Kysela <perex@perex.cz>
Tue, 3 Nov 2009 15:41:09 +0000 (16:41 +0100)
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 <john.lindgren@tds.net>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/dlmisc.c

index c882cdcf893abdeff2a32162feed6f1fac0481aa..3cca0f082e7be202725f8a0dc467948f9ea805bf 100644 (file)
@@ -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