Mesa (mesa_7_5_branch): mesa: don' t call getenv every time _mesa_error is called
Keith Whitwell
keithw at kemper.freedesktop.org
Wed Jul 15 12:32:26 UTC 2009
Module: Mesa
Branch: mesa_7_5_branch
Commit: 6c9d8a6f24db3c947928d72521d5fd544841366e
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6c9d8a6f24db3c947928d72521d5fd544841366e
Author: Keith Whitwell <keithw at vmware.com>
Date: Tue Jul 14 16:23:04 2009 +0100
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 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index 3fb6708..b0e7d9d 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;
More information about the mesa-commit
mailing list