]> git.ipfire.org Git - thirdparty/ipset.git/commit
ipset: improve command argument parsing
authorHolger Eitzenberger <holger@eitzenberger.org>
Tue, 1 Feb 2011 17:13:10 +0000 (18:13 +0100)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Tue, 1 Feb 2011 17:13:10 +0000 (18:13 +0100)
commitff1939dd4f7e1ccb2e98e2a17d8d2b8088fc2ac6
tree2c55402ba1a20474a2f33b36b2d8a11ec5c62497
parent004f06f32dd28f225a00d3ba7648a29eab28132e
ipset: improve command argument parsing

The number of comparisons for a matching a command name can be
made smaller by just checking on argv[1].

As an example consider the following 'create' arguments 'hashsize',
'family' and 'timeout'.  When having the command

 create foo hash:ip timeout 60 family inet hashsize 64

it compares without this patch:

 strcmp("timeout", "hashsize")
 strcmp("64", "hashsize")
 strcmp("family", "hashsize")
 strcmp("inet", "hashsize")
 strcmp("hashsize", "hashsize")

It is worse in practice, as 'create' has more arguments than this.

Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
src/ipset.c