aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-08-28 08:54:05 +0200
committerTeddy Wing2018-08-28 08:54:05 +0200
commit1814b50d5b96a3ddbf5fe1e3c8e781c53ac747c4 (patch)
treef7b7fe78643fad7ea1f994717e8c6cb27276cd01
parent2a3731003a53104340658c95491dc9587d2cea6c (diff)
downloadDomeKey-1814b50d5b96a3ddbf5fe1e3c8e781c53ac747c4.tar.bz2
HeadphoneKey(runAction): Use `while` loop over `result->action`
Using `strlen` loops once over the string, so along with our `for` loop, we have two loops over the string. No big deal since these shouldn't be that long. But, using a `while` loop we can iterate just once. Reference: Alexandre C. (https://stackoverflow.com/users/373025/alexandre-c) https://stackoverflow.com/questions/3213827/how-to-iterate-over-a-string-in-c/3213903#3213903
-rw-r--r--DomeKey/HeadphoneKey.m7
1 files changed, 5 insertions, 2 deletions
diff --git a/DomeKey/HeadphoneKey.m b/DomeKey/HeadphoneKey.m
index 1d5811b..515b7de 100644
--- a/DomeKey/HeadphoneKey.m
+++ b/DomeKey/HeadphoneKey.m
@@ -77,9 +77,12 @@
const CKeyActionResult *result = c_run_key_action(trigger, count);
if (*result->kind == MapKind_Map) {
- size_t length = strlen(result->action);
- for (size_t i = 0; i < length; i++) {
+ const char *c = result->action;
+ int i = 0;
+ while (*c) {
[KeyboardSimulator simpleKeyPressWithKey:result->action[i]];
+ i++;
+ *c++;
}
}