Coverity fixes: do { ...; continue; ... } while (false)

This is more stylistic than substantial, but it's bad enough
style to be worth fixing.
This commit is contained in:
John Hood
2016-05-11 00:03:37 -04:00
parent 9a6e0d576d
commit c1ca7e46a5
+4 -5
View File
@@ -475,8 +475,7 @@ void FrameState::append_silent_move( int y, int x )
void FrameState::append_move( int y, int x ) void FrameState::append_move( int y, int x )
{ {
do { // Only optimize if cursor pos is known
// If cursor pos is unknown, of course we can't optimize
if ( cursor_x != -1 && cursor_y != -1 ) { if ( cursor_x != -1 && cursor_y != -1 ) {
// Can we use CR and/or LF? They're cheap and easier to trace. // Can we use CR and/or LF? They're cheap and easier to trace.
if ( x == 0 && y - cursor_y >= 0 && y - cursor_y < 5 ) { if ( x == 0 && y - cursor_y >= 0 && y - cursor_y < 5 ) {
@@ -484,19 +483,19 @@ void FrameState::append_move( int y, int x )
append( '\r' ); append( '\r' );
} }
append( y - cursor_y, '\n' ); append( y - cursor_y, '\n' );
continue; goto positioned;
} }
// Backspaces are good too. // Backspaces are good too.
if ( y == cursor_y && x - cursor_x < 0 && x - cursor_x > -5 ) { if ( y == cursor_y && x - cursor_x < 0 && x - cursor_x > -5 ) {
append( cursor_x - x, '\b' ); append( cursor_x - x, '\b' );
continue; goto positioned;
} }
// More optimizations are possible. // More optimizations are possible.
} }
char tmp[ 64 ]; char tmp[ 64 ];
snprintf( tmp, 64, "\033[%d;%dH", y + 1, x + 1 ); snprintf( tmp, 64, "\033[%d;%dH", y + 1, x + 1 );
append( tmp ); append( tmp );
} while( 0 ); positioned:
cursor_x = x; cursor_x = x;
cursor_y = y; cursor_y = y;
} }