From 97f044d21f3e63ce03fc1839b35c7a74930ba47d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Monda?= Date: Sun, 5 Nov 2017 22:45:58 +0100 Subject: [PATCH] Simplify the control flow of UsbCommand_ApplyConfig() a bit. --- right/src/usb_commands/usb_command_apply_config.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/right/src/usb_commands/usb_command_apply_config.c b/right/src/usb_commands/usb_command_apply_config.c index 8824c79..88e6c7d 100644 --- a/right/src/usb_commands/usb_command_apply_config.c +++ b/right/src/usb_commands/usb_command_apply_config.c @@ -48,14 +48,12 @@ void UsbCommand_ApplyConfig(void) // Switch to the keymap of the updated configuration of the same name or the default keymap. for (uint8_t keymapId = 0; keymapId < AllKeymapsCount; keymapId++) { - if (AllKeymaps[keymapId].abbreviationLen != oldKeymapAbbreviationLen) { - continue; + if (AllKeymaps[keymapId].abbreviationLen == oldKeymapAbbreviationLen && + !memcmp(oldKeymapAbbreviation, AllKeymaps[keymapId].abbreviation, oldKeymapAbbreviationLen)) + { + SwitchKeymap(keymapId); + return; } - if (memcmp(oldKeymapAbbreviation, AllKeymaps[keymapId].abbreviation, oldKeymapAbbreviationLen)) { - continue; - } - SwitchKeymap(keymapId); - return; } SwitchKeymap(DefaultKeymapIndex);