[dev] [st][PATCH 4/4] Simplify expressions in tputc()

From: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Mon, 28 Apr 2014 10:25:28 +0200

---
 st.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/st.c b/st.c
index 339d8a9..470a34e 100644
--- a/st.c
+++ b/st.c
_AT_@ -2450,6 +2450,7 @@ tputc(char *c, int len) {
 	bool control;
 	long unicodep;
 	int width;
+	Glyph *gp;
 
 	if(len == 1) {
 		width = 1;
_AT_@ -2611,16 +2612,15 @@ tputc(char *c, int len) {
 		return;
 	if(sel.ob.x != -1 && BETWEEN(term.c.y, sel.ob.y, sel.oe.y))
 		selclear(NULL);
+
+	gp = &term.line[term.c.y][term.c.x];
 	if(IS_SET(MODE_WRAP) && (term.c.state & CURSOR_WRAPNEXT)) {
-		term.line[term.c.y][term.c.x].mode |= ATTR_WRAP;
+		gp->mode |= ATTR_WRAP;
 		tnewline(1);
 	}
 
-	if(IS_SET(MODE_INSERT) && term.c.x+1 < term.col) {
-		memmove(&term.line[term.c.y][term.c.x+1],
-			&term.line[term.c.y][term.c.x],
-			(term.col - term.c.x - 1) * sizeof(Glyph));
-	}
+	if(IS_SET(MODE_INSERT) && term.c.x+1 < term.col)
+		memmove(gp+1, gp, (term.col - term.c.x - 1) * sizeof(Glyph));
 
 	if(term.c.x+width > term.col)
 		tnewline(1);
_AT_@ -2628,10 +2628,10 @@ tputc(char *c, int len) {
 	tsetchar(c, &term.c.attr, term.c.x, term.c.y);
 
 	if(width == 2) {
-		term.line[term.c.y][term.c.x].mode |= ATTR_WIDE;
+		gp->mode |= ATTR_WIDE;
 		if(term.c.x+1 < term.col) {
-			term.line[term.c.y][term.c.x+1].c[0] = '\0';
-			term.line[term.c.y][term.c.x+1].mode = ATTR_WDUMMY;
+			gp[1].c[0] = '\0';
+			gp[1].mode = ATTR_WDUMMY;
 		}
 	}
 	if(term.c.x+width < term.col) {
-- 
1.8.5.3
Received on Mon Apr 28 2014 - 10:25:28 CEST

This archive was generated by hypermail 2.3.0 : Mon Apr 28 2014 - 10:36:18 CEST