From f0c061d141d014031c0962a828344fdfc4c91c32 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 17 Feb 2015 22:59:56 -0500 Subject: [PATCH] glX HasExtension(): check for NULL ext string first. It's slightly faster than failing later, after a strchr() call, since this will get called multiple times with a NULL string if the system totally fails elsewhere. --- src/video/x11/SDL_x11opengl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c index c46710f941b48..93dcd8c2ea298 100644 --- a/src/video/x11/SDL_x11opengl.c +++ b/src/video/x11/SDL_x11opengl.c @@ -279,14 +279,14 @@ HasExtension(const char *extension, const char *extensions) const char *start; const char *where, *terminator; + if (!extensions) + return SDL_FALSE; + /* Extension names should not have spaces. */ where = SDL_strchr(extension, ' '); if (where || *extension == '\0') return SDL_FALSE; - if (!extensions) - return SDL_FALSE; - /* It takes a bit of care to be fool-proof about parsing the * OpenGL extensions string. Don't be fooled by sub-strings, * etc. */