From 87fbf85995c8d52f4bcc28c055776e8b646b5182 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 6 Aug 2017 08:39:03 +0200 Subject: [PATCH] eventHandlerHook: Compute the one-shot index early Instead of computing the one-shot index when it is needed, compute it once at the beginning. Even if we don't use it, we still save a few bytes by not computing it in two branches. Signed-off-by: Gergely Nagy --- src/Kaleidoscope/OneShot.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Kaleidoscope/OneShot.cpp b/src/Kaleidoscope/OneShot.cpp index 2412a698..bc742305 100644 --- a/src/Kaleidoscope/OneShot.cpp +++ b/src/Kaleidoscope/OneShot.cpp @@ -81,7 +81,7 @@ void OneShot::cancelOneShot(uint8_t idx) { } Key OneShot::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_state) { - uint8_t idx; + uint8_t idx = mapped_key.raw - ranges::OS_FIRST; if (key_state & INJECTED) return mapped_key; @@ -91,7 +91,6 @@ Key OneShot::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_st return mapped_key; } - idx = mapped_key.raw - ranges::OS_FIRST; if (keyToggledOff(key_state)) { clearPressed(idx); } else if (keyToggledOn(key_state)) { @@ -114,8 +113,6 @@ Key OneShot::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_st return mapped_key; if (isOS(mapped_key)) { - idx = mapped_key.raw - ranges::OS_FIRST; - if (isSticky(idx)) { if (keyToggledOn(key_state)) { // maybe on _off instead? saveAsPrevious(mapped_key);