]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
speeding up (un)register_code16
authorSjB <steve@sagacity.ca>
Sat, 21 Jan 2017 07:01:55 +0000 (02:01 -0500)
committerSjB <steve@sagacity.ca>
Tue, 24 Jan 2017 04:16:57 +0000 (23:16 -0500)
In register_code16 and unregister_code16 we call register_code and
unregister_code twice, once for the mods and once for the keycode.
The (un)register_code have many check to see that keycode we have sent
however because we know that we are sending it a mods key, why not
just skip all of it and call (un)register_mods instead. This will skip
alot of checks and should speedup the loop a little.

quantum/quantum.c

index 63ffe2074e78773adb277707e33bb450194d51a5..1767faed42ca5e9be83e45d8bef4fd05a9b70739 100644 (file)
@@ -33,14 +33,22 @@ static void do_code16 (uint16_t code, void (*f) (uint8_t)) {
     f(KC_RGUI);
 }
 
+static inline void qk_register_mods(uint8_t kc) {
+  register_mods(MOD_BIT(kc));
+}
+
+static inline void qk_unregister_mods(uint8_t kc) {
+  unregister_mods(MOD_BIT(kc));
+}
+
 void register_code16 (uint16_t code) {
-  do_code16 (code, register_code);
+  do_code16 (code, qk_register_mods);
   register_code (code);
 }
 
 void unregister_code16 (uint16_t code) {
   unregister_code (code);
-  do_code16 (code, unregister_code);
+  do_code16 (code, qk_unregister_mods);
 }
 
 __attribute__ ((weak))