summary refs log tree commit diff
path: root/quantum/command.h
diff options
context:
space:
mode:
authorLiyang HU <github.com@liyang.hu>2021-08-07 08:12:57 +0100
committerGitHub <noreply@github.com>2021-08-07 17:12:57 +1000
commit383fae55c5d53626eda210298f15fa6810510d5e (patch)
tree001eabe3cab3ff3e45f06e64e260ec8c99f32312 /quantum/command.h
parenta03aa301def77c867ae6c6c840f7fc82b26d91d6 (diff)
Refactor `quantum/command.{c,h}` for code size & {read,maintain}ability (#11842)
* quantum/command.c: coalesce `print()`s in `command_common_help()` & `print_version()`

Also undo some damage by clang-format in b624f32f94

* quantum/command.c: replace `print(…); print_{,val_}{dec,hex}*(…);` sequences with single `xprintf(…)`

`print_{dec,hex}*(…)` are just `#define`s for `xprintf(…)` anyway.

Each additional `xprintf(…)` costs ~8 bytes: the call instructions,
plus an additional NUL terminator.

This _really_ adds up: this commit saves 814 bytes on my ATmega32.

* quantum/command.c: optimise `mousekey_console()` for size & legibility

Made various tweaks to the interface, but still functionally identical.

Assume `KC_1`…`KC_0` to be contiguous, and removed `numkey2num(…)` entirely.
It was exported in `command.h` by 1a0bac8bcc for no obvious reason, before
which it was `static`. I doubt anyone uses it.

`mousekey_console()` is now enabled regardless of `MK_3_SPEED`.
Needs fleshing out for things other than the X11 variant though.

This commit saves 638 bytes on my ATmega32.
Diffstat (limited to 'quantum/command.h')
-rw-r--r--quantum/command.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/quantum/command.h b/quantum/command.h
index 4f77be085c..676507d3bd 100644
--- a/quantum/command.h
+++ b/quantum/command.h
@@ -28,8 +28,7 @@ bool command_extra(uint8_t code);
 bool command_console_extra(uint8_t code);
 
 #ifdef COMMAND_ENABLE
-uint8_t numkey2num(uint8_t code);
-bool    command_proc(uint8_t code);
+bool command_proc(uint8_t code);
 #else
 #    define command_proc(code) false
 #endif