From: Keith Whitwell Date: Tue, 14 Jul 2009 15:23:04 +0000 (+0100) Subject: mesa: don't call getenv every time _mesa_error is called X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6c9d8a6f24db3c947928d72521d5fd544841366e;p=mesa.git mesa: don't call getenv every time _mesa_error is called Buggy apps can generate thousands of mesa_error calls. Don't need to keep calling getenv to retreive the same MESA_DEBUG string each time. --- diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 3fb67083a2d..b0e7d9d4835 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -1081,22 +1081,25 @@ _mesa_problem( const GLcontext *ctx, const char *fmtString, ... ) void _mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... ) { - const char *debugEnv; - GLboolean debug; + static GLint debug = -1; - debugEnv = _mesa_getenv("MESA_DEBUG"); + /* Check debug environment variable only once: + */ + if (debug == -1) { + const char *debugEnv = _mesa_getenv("MESA_DEBUG"); #ifdef DEBUG - if (debugEnv && _mesa_strstr(debugEnv, "silent")) - debug = GL_FALSE; - else - debug = GL_TRUE; + if (debugEnv && _mesa_strstr(debugEnv, "silent")) + debug = GL_FALSE; + else + debug = GL_TRUE; #else - if (debugEnv) - debug = GL_TRUE; - else - debug = GL_FALSE; + if (debugEnv) + debug = GL_TRUE; + else + debug = GL_FALSE; #endif + } if (debug) { va_list args;