diff options
author | Brian Paul <[email protected]> | 2010-04-20 16:13:08 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2010-04-20 16:17:09 -0600 |
commit | f4dcb5de4e46d7b511b530375ef77e9946b89ff0 (patch) | |
tree | e66e60b92fdc541f37297a6620068073241d7f40 /src | |
parent | f86d7af4a0003997890edc84158e72c21c11037e (diff) |
mesa: better, smaller error handling code for glEnable/Disable/IsEnabled()
Use a goto instead of replicating the _mesa_error() call many times.
enable.o is about 15% smaller.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/enable.c | 53 |
1 files changed, 29 insertions, 24 deletions
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index f9decc31ab7..d24564c3537 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -42,9 +42,7 @@ #define CHECK_EXTENSION(EXTNAME, CAP) \ if (!ctx->Extensions.EXTNAME) { \ - _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(0x%x)", \ - state ? "Enable" : "Disable", CAP); \ - return; \ + goto invalid_enum_error; \ } @@ -127,9 +125,7 @@ client_state(GLcontext *ctx, GLenum cap, GLboolean state) #endif /* FEATURE_NV_vertex_program */ default: - _mesa_error( ctx, GL_INVALID_ENUM, - "glEnable/DisableClientState(0x%x)", cap); - return; + goto invalid_enum_error; } if (*var == state) @@ -150,6 +146,12 @@ client_state(GLcontext *ctx, GLenum cap, GLboolean state) if (ctx->Driver.Enable) { ctx->Driver.Enable( ctx, cap, state ); } + + return; + +invalid_enum_error: + _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(0x%x)", + state ? "Enable" : "Disable", cap); } @@ -188,16 +190,12 @@ _mesa_DisableClientState( GLenum cap ) #undef CHECK_EXTENSION #define CHECK_EXTENSION(EXTNAME, CAP) \ if (!ctx->Extensions.EXTNAME) { \ - _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \ - state ? "Enable" : "Disable", CAP); \ - return; \ + goto invalid_enum_error; \ } #define CHECK_EXTENSION2(EXT1, EXT2, CAP) \ if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ - _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \ - state ? "Enable" : "Disable", CAP); \ - return; \ + goto invalid_enum_error; \ } @@ -993,14 +991,18 @@ _mesa_set_enable(GLcontext *ctx, GLenum cap, GLboolean state) #endif default: - _mesa_error(ctx, GL_INVALID_ENUM, - "%s(0x%x)", state ? "glEnable" : "glDisable", cap); - return; + goto invalid_enum_error; } if (ctx->Driver.Enable) { ctx->Driver.Enable( ctx, cap, state ); } + + return; + +invalid_enum_error: + _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", + state ? "Enable" : "Disable", cap); } @@ -1043,7 +1045,7 @@ _mesa_set_enablei(GLcontext *ctx, GLenum cap, GLuint index, GLboolean state) switch (cap) { case GL_BLEND: if (!ctx->Extensions.EXT_draw_buffers2) { - goto bad_cap_error; + goto invalid_enum_error; } if (index >= ctx->Const.MaxDrawBuffers) { _mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", @@ -1059,11 +1061,11 @@ _mesa_set_enablei(GLcontext *ctx, GLenum cap, GLuint index, GLboolean state) } break; default: - goto bad_cap_error; + goto invalid_enum_error; } return; -bad_cap_error: +invalid_enum_error: _mesa_error(ctx, GL_INVALID_ENUM, "%s(cap=%s)", state ? "glEnablei" : "glDisablei", _mesa_lookup_enum_by_nr(cap)); @@ -1113,15 +1115,13 @@ _mesa_IsEnabledIndexed( GLenum cap, GLuint index ) #undef CHECK_EXTENSION #define CHECK_EXTENSION(EXTNAME) \ if (!ctx->Extensions.EXTNAME) { \ - _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \ - return GL_FALSE; \ + goto invalid_enum_error; \ } #undef CHECK_EXTENSION2 #define CHECK_EXTENSION2(EXT1, EXT2) \ if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \ - _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \ - return GL_FALSE; \ + goto invalid_enum_error; \ } @@ -1510,7 +1510,12 @@ _mesa_IsEnabled( GLenum cap ) #endif default: - _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap); - return GL_FALSE; + goto invalid_enum_error; } + + return GL_FALSE; + +invalid_enum_error: + _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap); + return GL_FALSE; } |