[hackers] [st] Clarify some or exclusive expressions || "Roberto E. Vargas Caballero"

From: <hg_AT_suckless.org>
Date: Thu, 8 Nov 2012 17:24:46 +0100 (CET)

changeset: 389:bf2606eb989a
user: "Roberto E. Vargas Caballero" <k0ga_AT_shike2.com>
date: Thu Nov 08 17:17:26 2012 +0100
files: st.c
description:
Clarify some or exclusive expressions
Since relational expresions are always evaluated to 0 or 1, we can use
bitwise xor operator instead of using more complex boolean expressions.
---
 st.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
diff -r 3515a58a56c8 -r bf2606eb989a st.c
--- a/st.c	Thu Nov 08 17:15:26 2012 +0100
+++ b/st.c	Thu Nov 08 17:17:26 2012 +0100
_AT_@ -1475,15 +1475,15 @@
 				break;
 			case 1049: /* = 1047 and 1048 */
 			case 47:
-			case 1047:
-				if(IS_SET(MODE_ALTSCREEN))
+			case 1047: {
+				bool alt = IS_SET(MODE_ALTSCREEN) != 0;
+				if(alt)
 					tclearregion(0, 0, term.col-1, term.row-1);
-				if((set && !IS_SET(MODE_ALTSCREEN)) ||
-						(!set && IS_SET(MODE_ALTSCREEN))) {
+				if(set ^ alt)		/* set is always 1 or 0 */
 					tswapscreen();
-				}
 				if(*args != 1049)
 					break;
+			}
 				/* pass through */
 			case 1048:
 				tcursor((set) ? CURSOR_SAVE : CURSOR_LOAD);
_AT_@ -2546,9 +2546,9 @@
 	int ic, ib, x, y, ox, sl;
 	Glyph base, new;
 	char buf[DRAW_BUF_SIZ];
-	bool ena_sel = sel.bx != -1, alt = IS_SET(MODE_ALTSCREEN);
+	bool ena_sel = sel.bx != -1, alt = IS_SET(MODE_ALTSCREEN) != 0;
 
-	if((sel.alt && !alt) || (!sel.alt && alt))
+	if((sel.alt != 0) ^ alt)
 		ena_sel = 0;
 	if(!(xw.state & WIN_VISIBLE))
 		return;
Received on Thu Nov 08 2012 - 17:24:46 CET

This archive was generated by hypermail 2.3.0 : Thu Nov 08 2012 - 17:36:08 CET