From 6c9d8a6f24db3c947928d72521d5fd544841366e Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 14 Jul 2009 16:23:04 +0100 Subject: 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. --- src/mesa/main/imports.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src/mesa/main') 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; -- cgit v1.2.3