Skip to contentSkip to conversation

drivers/sbus/char: Micro-optimization in display7seg.c

PATCH Applied Rasmus Villemoes 2 participants 2 messages Jun 19, 2014 – Jul 22, 2014 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/sbus/char: Micro-optimization in display7seg.c

Flipping a bit doesn't need four lines of code; and gcc seems to actually generate two branches.

---
 drivers/sbus/char/display7seg.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/sbus/char/display7seg.c +1 -4
index 7c71e7b..3221dff 100644
@@ -143,10 +143,7 @@ static long d7s_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
 	case D7SIOCTM:
 		/* toggle device mode-- flip display orientation */
-		if (regs & D7S_FLIP)
-			regs &= ~D7S_FLIP;
-		else
-			regs |= D7S_FLIP;
+		regs ^= D7S_FLIP;
 		writeb(regs, p->regs);
 		break;
 	}
Signature · 1 line
1.9.2