From 2be3fef5381893354e7f504edc5ae81d506c2ca2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Fri, 10 Jan 2025 17:50:50 -0500
Subject: [PATCH] Don't calculate the same value twice.

---
 src/conio/bitmap_con.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/conio/bitmap_con.c b/src/conio/bitmap_con.c
index 8f63b2a783..f841823a07 100644
--- a/src/conio/bitmap_con.c
+++ b/src/conio/bitmap_con.c
@@ -668,6 +668,7 @@ draw_char_row(struct blockstate *bs, struct charstate *cs, uint32_t y)
 
 	uint8_t fb = cs->font[cs->fontoffset];
 	for(unsigned x = 0; x < vstat.charwidth; x++) {
+		unsigned bitnum = x & 0x07;
 		if (bs->expand && x == bs->font_data_width) {
 			if (cs->gexpand)
 				fbb = cs->font[cs->fontoffset - 1] & (0x80 >> ((x - 1) & 7));
@@ -675,9 +676,9 @@ draw_char_row(struct blockstate *bs, struct charstate *cs, uint32_t y)
 				fbb = 0;
 		}
 		else
-			fbb = fb & (0x80 >> (x & 7));
+			fbb = fb & (0x80 >> bitnum);
 
-		if ((x & 0x07) == 7) {
+		if (bitnum == 7) {
 			cs->fontoffset++;
 			fb = cs->font[cs->fontoffset];
 		}
@@ -725,6 +726,7 @@ draw_char_row_double(struct blockstate *bs, struct charstate *cs, uint32_t y)
 
 	uint8_t fb = cs->font[cs->fontoffset];
 	for(unsigned x = 0; x < vstat.charwidth; x++) {
+		unsigned bitnum = x & 0x07;
 		if (bs->expand && x == bs->font_data_width) {
 			if (cs->gexpand)
 				fbb = cs->font[cs->fontoffset - 1] & (0x80 >> ((x - 1) & 7));
@@ -732,9 +734,9 @@ draw_char_row_double(struct blockstate *bs, struct charstate *cs, uint32_t y)
 				fbb = 0;
 		}
 		else
-			fbb = fb & (0x80 >> (x & 7));
+			fbb = fb & (0x80 >> bitnum);
 
-		if ((x & 0x07) == 7) {
+		if (bitnum == 7) {
 			cs->fontoffset++;
 			fb = cs->font[cs->fontoffset];
 		}
-- 
GitLab