[dev] [st] [PATCH 1/3] tresize: move for loop outside if

From: noname <noname_AT_inventati.org>
Date: Sat, 11 Apr 2015 17:29:28 +0000

There is no need to check that slide > 0 before executing loop.
If slide <= 0, loop stops immediately.
---
 st.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/st.c b/st.c
index b4e17e4..3b45c42 100644
--- a/st.c
+++ b/st.c
_AT_@ -2781,17 +2781,16 @@ tresize(int col, int row) {
 	}
 
 	/* free unneeded rows */
-	i = 0;
+	for(i = 0; i < slide; i++) {
+		free(term.line[i]);
+		free(term.alt[i]);
+	}
 	if(slide > 0) {
 		/*
 		 * slide screen to keep cursor where we expect it -
 		 * tscrollup would work here, but we can optimize to
 		 * memmove because we're freeing the earlier lines
 		 */
-		for(/* i = 0 */; i < slide; i++) {
-			free(term.line[i]);
-			free(term.alt[i]);
-		}
 		memmove(term.line, term.line + slide, row * sizeof(Line));
 		memmove(term.alt, term.alt + slide, row * sizeof(Line));
 	}
-- 
1.8.4
Received on Sat Apr 11 2015 - 19:29:28 CEST

This archive was generated by hypermail 2.3.0 : Sat Apr 11 2015 - 19:36:07 CEST