]> sourceware.org Git - lvm2.git/commit
commands: optimize binary search
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 17 Feb 2017 09:00:43 +0000 (10:00 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 17 Feb 2017 12:20:55 +0000 (13:20 +0100)
commit772834e40aef44a8f7bc884050e1b88087073706
tree6cf72d56943ab08b1e24b2de1e7852ba5dee6238
parent582a272b3f401e1bb6eafaa52d0ed1d318d04a9f
commands: optimize binary search

Since there is a lot of options and lot of searches,
use binary search to keep strcmp at minimum.

The interesting part is - alphabetically sorted array contains
duplicates and some of them are not the 'right anwer', so
after we find matching string but not matching long_ARG,
we may need to check if the surrouding strings are the right matching
one.

The single loops is used also for strictly define --foo_long
(i.e. --stripes)  and just differs at final part.

TODO1: replace strstr call with some flag (just like short_opt).
TODO2: drop '--' from being stored and tests by strcmp.
tools/command.c
This page took 0.027215 seconds and 5 git commands to generate.