diff options
author | Ron Yorston <rmy@pobox.com> | 2021-01-29 13:22:48 +0000 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-02-02 14:16:38 +0100 |
commit | 59120c330330467c9e6aaec6d4ca8295baa653af (patch) | |
tree | d22982ca2eac6d933d9e68bb3aa81d3e9032e49b /coreutils/uname.c | |
parent | e8fe9f96356a6b19ec907ea30cffc829c539a7ff (diff) |
libbb: code shrink and speed up find_applet_by_name()
find_applet_by_name() determines the appropriate range of applet
indices to check for the given name and performs a linear search in
applet_names[].
Revise the code so the index of the upper bound of the range, 'max',
isn't calculated. Instead check the value of the first non-matching
character to see if we've reached the end of the range.
This new code speeds up the time to find a valid applet name by 6%
and halves the time to detect that a given name is invalid. The
average time to detect an invalid name is now the same as for a valid
one.
function old new delta
find_applet_by_name 155 133 -22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-22) Total: -22 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'coreutils/uname.c')
0 files changed, 0 insertions, 0 deletions