summaryrefslogtreecommitdiffstats
path: root/src/glx/g_glxglvnddispatchfuncs.c
diff options
context:
space:
mode:
authorEmil Velikov <[email protected]>2016-05-11 14:01:55 -0400
committerEmil Velikov <[email protected]>2016-05-30 17:53:44 +0100
commit3bf00b6c6ac108f7d6cfc5c36401ccfd6a378469 (patch)
treecef56ea0e3748053be7c34433baf4208cb6e1b05 /src/glx/g_glxglvnddispatchfuncs.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 <[email protected]> Signed-off-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/glx/g_glxglvnddispatchfuncs.c')
-rw-r--r--src/glx/g_glxglvnddispatchfuncs.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/glx/g_glxglvnddispatchfuncs.c b/src/glx/g_glxglvnddispatchfuncs.c
index 13fbc5ea81b..72f0f68bf39 100644
--- a/src/glx/g_glxglvnddispatchfuncs.c
+++ b/src/glx/g_glxglvnddispatchfuncs.c
@@ -9,7 +9,8 @@
#include "g_glxglvnddispatchindices.h"
const int DI_FUNCTION_COUNT = DI_LAST_INDEX;
-int __glXDispatchTableIndices[DI_LAST_INDEX];
+/* Allocate an extra 'dummy' to ease lookup. See FindGLXFunction() */
+int __glXDispatchTableIndices[DI_LAST_INDEX + 1];
const __GLXapiExports *__glXGLVNDAPIExports;
const char * const __glXDispatchTableStrings[DI_LAST_INDEX] = {
@@ -922,7 +923,8 @@ static Bool dispatch_glXWaitForSbcOML(Display *dpy, GLXDrawable drawable,
#undef __FETCH_FUNCTION_PTR
-const void * const __glXDispatchFunctions[DI_LAST_INDEX] = {
+/* Allocate an extra 'dummy' to ease lookup. See FindGLXFunction() */
+const void * const __glXDispatchFunctions[DI_LAST_INDEX + 1] = {
#define __ATTRIB(field) \
[DI_##field] = (void *)dispatch_##field
@@ -972,5 +974,6 @@ const void * const __glXDispatchFunctions[DI_LAST_INDEX] = {
__ATTRIB(glXWaitForMscOML),
__ATTRIB(glXWaitForSbcOML),
+ [DI_LAST_INDEX] = NULL,
#undef __ATTRIB
};