aboutsummaryrefslogtreecommitdiff
path: root/input.c
diff options
context:
space:
mode:
authorCraig Barnes <craigbarnes@protonmail.com>2022-04-06 00:24:34 +0000
committerDaniel Eklöf <daniel@ekloef.se>2022-04-06 16:19:47 +0000
commit0d1e6960af35ab4aa289e4e0c2443320e2a3adb0 (patch)
treed7c5396acf3a2970f39c5d8a050e6dd57cedb632 /input.c
parentrender: ensure an underline cursor is not positioned too low (diff)
osc: avoid unnecessary calls to strlen(3)
Checking for specific strings of length 0 or 1 can be done with e.g.: if (str[0] == '\0') {...} if (str[0] == '?' && str[1] == '\0') {...} Doing it this way instead of using strlen(3) means we avoid the function call overhead and also avoid scanning through more of the string than is neceessary. A compiler could perhaps optimize away calls to strlen(3) when the result is compared to a small constant, but GCC 11.2 only seems to actually do this[1] for lengths of 0. [1]: https://godbolt.org/z/qxoW8qqW6
Diffstat (limited to 'input.c')
0 files changed, 0 insertions, 0 deletions