[PATCH] Refactor xdraws() - Episode II

From: FRIGN <dev_AT_frign.de>
Date: Sat, 7 Jun 2014 18:55:20 +0200

Remove the number of temporary RenderColor-Objects and just use one.
---
 st.c | 40 +++++++++++++++++++---------------------
 1 file changed, 19 insertions(+), 21 deletions(-)
diff --git a/st.c b/st.c
index ba0bf72..f8c7afa 100644
--- a/st.c
+++ b/st.c
_AT_@ -3108,7 +3108,7 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
 	FcFontSet *fcsets[] = { NULL };
 	FcCharSet *fccharset;
 	Color *fg, *bg, *temp, revfg, revbg, truefg, truebg;
-	XRenderColor colfg, colbg;
+	XRenderColor color = { .alpha = 0xffff };
 	XRectangle r;
 	int oneatatime;
 
_AT_@ -3134,22 +3134,20 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
 	}
 
 	if(IS_TRUECOL(base.fg)) {
-		colfg.alpha = 0xffff;
-		colfg.red = TRUERED(base.fg);
-		colfg.green = TRUEGREEN(base.fg);
-		colfg.blue = TRUEBLUE(base.fg);
-		XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colfg, &truefg);
+		color.red = TRUERED(base.fg);
+		color.green = TRUEGREEN(base.fg);
+		color.blue = TRUEBLUE(base.fg);
+		XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &color, &truefg);
 		fg = &truefg;
 	} else {
 		fg = &dc.col[base.fg];
 	}
 
 	if(IS_TRUECOL(base.bg)) {
-		colbg.alpha = 0xffff;
-		colbg.green = TRUEGREEN(base.bg);
-		colbg.red = TRUERED(base.bg);
-		colbg.blue = TRUEBLUE(base.bg);
-		XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colbg, &truebg);
+		color.green = TRUEGREEN(base.bg);
+		color.red = TRUERED(base.bg);
+		color.blue = TRUEBLUE(base.bg);
+		XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &color, &truebg);
 		bg = &truebg;
 	} else {
 		bg = &dc.col[base.bg];
_AT_@ -3159,11 +3157,11 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
 		if(fg == &dc.col[defaultfg]) {
 			fg = &dc.col[defaultbg];
 		} else {
-			colfg.red = ~fg->color.red;
-			colfg.green = ~fg->color.green;
-			colfg.blue = ~fg->color.blue;
-			colfg.alpha = fg->color.alpha;
-			XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colfg,
+			color.red = ~fg->color.red;
+			color.green = ~fg->color.green;
+			color.blue = ~fg->color.blue;
+			color.alpha = fg->color.alpha;
+			XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &color,
 					&revfg);
 			fg = &revfg;
 		}
_AT_@ -3171,11 +3169,11 @@ xdraws(char *s, Glyph base, int x, int y, int charlen, int bytelen) {
 		if(bg == &dc.col[defaultbg]) {
 			bg = &dc.col[defaultfg];
 		} else {
-			colbg.red = ~bg->color.red;
-			colbg.green = ~bg->color.green;
-			colbg.blue = ~bg->color.blue;
-			colbg.alpha = bg->color.alpha;
-			XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colbg,
+			color.red = ~bg->color.red;
+			color.green = ~bg->color.green;
+			color.blue = ~bg->color.blue;
+			color.alpha = bg->color.alpha;
+			XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &color,
 					&revbg);
 			bg = &revbg;
 		}
-- 
1.8.5.5
--Multipart=_Sat__7_Jun_2014_18_59_24_+0200_lO5g_j.tWdTlEh6C--
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Sat Jun 07 2014 - 21:48:03 CEST