From aeeabeff937d06e051ff7a10e94959a48b0f71c8 Mon Sep 17 00:00:00 2001 From: rkrolib Date: Fri, 7 Nov 2003 06:12:58 +0000 Subject: [PATCH] Slight style improvements. Two rules of thumb that are almost always good to apply: * Don't write a == CONST. Instead, write CONST == a. Or, more generally (in C like languages): Avoid putting an lvalue on the left-hand side of an == comparison. (For consistancy, I try to avoid lvalues on the left- hand side of any comparison---but == is the most notorious.) (An "lvalue" is a value that can safely go on the left side of an "=" assignment, of course. (^&) * Do not write if( !condition ) return; other_thing; return; (See page 18 of K&P's _The Elements of Programming Style_.) Instead, it is better to just write: if( condition ) other_thing; return; There are times when sacrificing structured programming (e.g., via multiple return statements) is okay. But, here, there is no apparent gain---indeed, there seems only loss---in the non-structured code. git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@308 7f0cb862-5218-0410-a997-914c9d46530a --- freeglut/freeglut/src/freeglut_callbacks.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/freeglut/freeglut/src/freeglut_callbacks.c b/freeglut/freeglut/src/freeglut_callbacks.c index f34fe1b..9eee649 100644 --- a/freeglut/freeglut/src/freeglut_callbacks.c +++ b/freeglut/freeglut/src/freeglut_callbacks.c @@ -115,19 +115,14 @@ void FGAPIENTRY glutTimerFunc( unsigned int timeOut, void (* callback)( int ), */ static void fghVisibility( int status ) { - FGCBVisibility vis; - int glut_status; + int glut_status = GLUT_VISIBLE; freeglut_assert_ready; freeglut_return_if_fail( fgStructure.Window ); - vis = FETCH_WCB( ( *( fgStructure.Window ) ), Visibility ); - freeglut_return_if_fail( vis ); - if( status == GLUT_HIDDEN || status == GLUT_FULLY_COVERED ) + if( ( GLUT_HIDDEN == status ) || ( GLUT_FULLY_COVERED == status ) ) glut_status = GLUT_NOT_VISIBLE; - else - glut_status = GLUT_VISIBLE; - vis( glut_status ); + INVOKE_WCB( *( fgStructure.Window ), Visibility, ( glut_status ) ); } void FGAPIENTRY glutVisibilityFunc( void (* callback)( int ) ) @@ -232,9 +227,8 @@ void FGAPIENTRY glutWMCloseFunc( void (* callback)( void ) ) /* A. Donev: Destruction callback for menus */ void FGAPIENTRY glutMenuDestroyFunc( void (* callback)( void ) ) { - if( fgStructure.Menu == NULL ) - return; - fgStructure.Menu->Destroy = callback; + if( fgStructure.Menu ) + fgStructure.Menu->Destroy = callback; } /*