mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-17 21:22:05 +00:00
UNICODE_MODE_VIM: a bit less code, a bit more cpu usage
All the loop is reused now, and there is no duplicated code But we have one extra check for each of 4 first digits, that is 4 checks for a character In previous version there was only 1 check for each unicode character.
This commit is contained in:
parent
fc09ffb34a
commit
6fcc2ba921
@ -350,16 +350,6 @@ void register_hex(uint16_t hex) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void register_hex32(uint32_t hex) {
|
void register_hex32(uint32_t hex) {
|
||||||
// In vim, `i_CTRL-V U` waits for exactly 8 digits, so we send them all
|
|
||||||
// @see `:h i_CTRL-V_digit`
|
|
||||||
if (unicode_config.input_mode == UNICODE_MODE_VIM) {
|
|
||||||
for (int i = 7; i >= 0; i--) {
|
|
||||||
uint8_t digit = ((hex >> (i * 4)) & 0xF);
|
|
||||||
send_nibble(digit);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool first_digit = true;
|
bool first_digit = true;
|
||||||
bool needs_leading_zero = (unicode_config.input_mode == UNICODE_MODE_WINCOMPOSE);
|
bool needs_leading_zero = (unicode_config.input_mode == UNICODE_MODE_WINCOMPOSE);
|
||||||
for (int i = 7; i >= 0; i--) {
|
for (int i = 7; i >= 0; i--) {
|
||||||
@ -372,9 +362,13 @@ void register_hex32(uint32_t hex) {
|
|||||||
send_nibble_wrapper(0);
|
send_nibble_wrapper(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always send digits (including zero) if we're down to the last
|
bool must_send =
|
||||||
// two bytes of nibbles.
|
// Always send digits (including zero) if we're down to the last
|
||||||
bool must_send = i < 4;
|
// two bytes of nibbles.
|
||||||
|
(i < 4)
|
||||||
|
// In vim, `i_CTRL-V U` waits for exactly 8 digits, so we send them all
|
||||||
|
// @see `:h i_CTRL-V_digit`
|
||||||
|
|| (unicode_config.input_mode == UNICODE_MODE_VIM);
|
||||||
|
|
||||||
// If we've found a digit worth transmitting, do so.
|
// If we've found a digit worth transmitting, do so.
|
||||||
if (digit != 0 || !first_digit || must_send) {
|
if (digit != 0 || !first_digit || must_send) {
|
||||||
|
Loading…
Reference in New Issue
Block a user