summaryrefslogtreecommitdiff
path: root/src/glx/glxglvnd.c
diff options
context:
space:
mode:
authorEmil Velikov <emil.velikov@collabora.com>2016-05-11 14:01:55 -0400
committerEmil Velikov <emil.l.velikov@gmail.com>2016-05-30 17:53:44 +0100
commit3bf00b6c6ac108f7d6cfc5c36401ccfd6a378469 (patch)
treecef56ea0e3748053be7c34433baf4208cb6e1b05 /src/glx/glxglvnd.c
parenteab7e54981017d7b87242505a215a370dfcd5024 (diff)
glx/glvnd: rework dispatch functions/indices tables lookup
Rather than checking if the function name maps to a valid entry in the respective table, just create a dummy entry at the end of each table. This allows us to remove some unnessesary "index >= 0" checks, which get executed quite often. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Diffstat (limited to 'src/glx/glxglvnd.c')
-rw-r--r--src/glx/glxglvnd.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/glx/glxglvnd.c b/src/glx/glxglvnd.c
index 96cd1fd7e95..b7252a791ad 100644
--- a/src/glx/glxglvnd.c
+++ b/src/glx/glxglvnd.c
@@ -17,7 +17,7 @@ static void *__glXGLVNDGetProcAddress(const GLubyte *procName)
return glXGetProcAddressARB(procName);
}
-static int FindGLXFunction(const GLubyte *name)
+static unsigned FindGLXFunction(const GLubyte *name)
{
unsigned first = 0;
unsigned last = DI_FUNCTION_COUNT - 1;
@@ -34,26 +34,23 @@ static int FindGLXFunction(const GLubyte *name)
else
return middle;
}
- return -1;
+
+ /* Just point to the dummy entry at the end of the respective table */
+ return DI_FUNCTION_COUNT;
}
static void *__glXGLVNDGetDispatchAddress(const GLubyte *procName)
{
- int internalIndex = FindGLXFunction(procName);
-
- if (internalIndex >= 0) {
- return __glXDispatchFunctions[internalIndex];
- }
+ unsigned internalIndex = FindGLXFunction(procName);
- return NULL;
+ return __glXDispatchFunctions[internalIndex];
}
static void __glXGLVNDSetDispatchIndex(const GLubyte *procName, int index)
{
- int internalIndex = FindGLXFunction(procName);
+ unsigned internalIndex = FindGLXFunction(procName);
- if (internalIndex >= 0)
- __glXDispatchTableIndices[internalIndex] = index;
+ __glXDispatchTableIndices[internalIndex] = index;
}
_X_EXPORT Bool __glx_Main(uint32_t version, const __GLXapiExports *exports,