-
-
Notifications
You must be signed in to change notification settings - Fork 39.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor quantum/command.{c,h}
for code size & {read,maintain}ability
#11842
Conversation
d7311b0
to
2d625a7
Compare
2d625a7
to
83bae0b
Compare
Travis errored on something unrelated:
|
…print_version()` Also undo some damage by clang-format in b624f32
…quences 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.
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 1a0bac8 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.
83bae0b
to
a6576c5
Compare
This mostly looks good, but I would have preferred if the last change a6576c5 were done in a separate PR. |
a6576c5
to
3ec12a5
Compare
Done! |
Sorry about that, GitHub decided to delete the |
Thank you for your contribution! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__attribute__ ((weak))
Thank you for your contribution! |
@@ -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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think clang-format will disagree with this (at least, the version of clang-format that the Docker image uses).
* qmk/develop: (175 commits) Add support for STM32F407x MCUs. (qmk#13718) [Keyboard] Add Pancake v2 (qmk#13839) [Keyboard] Added CapsLED and ScrollLock LEDs (qmk#13837) [Keymap] Drashna split transport improvement (qmk#13905) [Keyboard] a1200 converter minor changes (qmk#13848) [Keyboard] Gorthage Truck - New PCB (qmk#13909) [Keyboard] Clean up lfkpad and add keymap (qmk#13881) [Keyboard] Adding my Nyquist keymap (qmk#13858) [Keyboard] Fix matrix_output_unselect_delay for handwired/xealousbrown (qmk#13913) [Keyboard] fixes for KBD67 rev2 (qmk#13906) Clean up remaining RGB_DISABLE_WHEN_USB_SUSPENDED defines Part 2 (qmk#13912) Refactor `quantum/command.{c,h}` for code size & {read,maintain}ability (qmk#11842) Remove Full Bootmagic (qmk#13846) [Keyboard] Added 67mk_E PCB (qmk#13869) [Keyboard] Modify key drive pins for mojo68 (qmk#13863) [Keyboard] Use new matrix_output_select_delay api (qmk#13861) [Keyboard] add handwired/oem_ansi_fullsize (qmk#13857) [Keymap] JackKenney's keymap for GMMK Pro (qmk#13853) [Keyboard] Fix oled_task_user for chocolatebar (qmk#13911) clean up CRLF instances (qmk#13910) ...
…ty (qmk#11842) * quantum/command.c: coalesce `print()`s in `command_common_help()` & `print_version()` Also undo some damage by clang-format in b624f32 * 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 1a0bac8 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.
…ty (qmk#11842) * quantum/command.c: coalesce `print()`s in `command_common_help()` & `print_version()` Also undo some damage by clang-format in c3e062c * 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 ffc1b68 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.
I accidentally a huge refactor. (This is part 1 of n.) It improves the code size & {read,maintain}ability significantly.
This PR reduces the firmware size by ~1.5kB on my ATmega32, when built with
CONSOLE_ENABLE
andCOMMAND_ENABLE
set toyes
.If possible, could this PR be merged rather than squashed?
Description
Because the last commit moves
mousekey_console()
tomousekey.c
(verbatim, trust me :), I recommend reading the penultimate commit separately to see the changes tomousekey_console()
itself.Types of Changes
Issues Fixed or Closed by This PR
n/aChecklist
My change requires a change to the documentation.I have updated the documentation accordingly.I have added tests to cover my changes.