aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2009-07-14 16:23:04 +0100
committerKeith Whitwell <[email protected]>2009-07-15 13:31:50 +0100
commit6c9d8a6f24db3c947928d72521d5fd544841366e (patch)
treec73a4d530c100ee7a9597e91423d3a75bb070e33 /src/mesa/main
parent9aca6769dfb934e15e848f938b7fb31345a8b3b2 (diff)
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.
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/imports.c25
1 files changed, 14 insertions, 11 deletions
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;