[dev] [st][PATCH] Simplify a bit more tdeletechar and tinsertblank

From: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Fri, 25 Apr 2014 17:30:33 +0200

The large and repeated expression used in memmove to indirect
the line can be simplified using a pointer, that makes more
clear where begins and where ends the movement.
---
 st.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/st.c b/st.c
index 263abaa..e468d73 100644
--- a/st.c
+++ b/st.c
_AT_@ -1587,30 +1587,32 @@ tclearregion(int x1, int y1, int x2, int y2) {
 void
 tdeletechar(int n) {
 	int dst, src, size;
+	Glyph *line;
 
 	LIMIT(n, 0, term.col - term.c.x);
 
 	dst = term.c.x;
 	src = term.c.x + n;
 	size = term.col - src;
+	line = term.line[term.c.y];
 
-	memmove(&term.line[term.c.y][dst], &term.line[term.c.y][src],
-	        size * sizeof(Glyph));
+	memmove(&line[dst], &line[src], size * sizeof(Glyph));
 	tclearregion(term.col-n, term.c.y, term.col-1, term.c.y);
 }
 
 void
 tinsertblank(int n) {
 	int dst, src, size;
+	Glyph *line;
 
 	LIMIT(n, 0, term.col - term.c.x);
 
 	dst = term.c.x + n;
 	src = term.c.x;
 	size = term.col - dst;
+	line = term.line[term.c.y];
 
-	memmove(&term.line[term.c.y][dst], &term.line[term.c.y][src],
-	        size * sizeof(Glyph));
+	memmove(&line[dst], &line[src], size * sizeof(Glyph));
 	tclearregion(src, term.c.y, dst - 1, term.c.y);
 }
 
-- 
1.8.5.3
Received on Fri Apr 25 2014 - 17:30:33 CEST

This archive was generated by hypermail 2.3.0 : Fri Apr 25 2014 - 17:36:07 CEST