xstrstr: speed up analysis by avoiding string comparisons

With large input one should see cut 15% for overall run time.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2013-08-31 00:30:28 +01:00
parent d70b08244f
commit 06ffa5ed04
5 changed files with 102 additions and 98 deletions

View file

@ -52,32 +52,4 @@ static const size_t MAXLEN = 1024;
* \brief Maximum number of different shared networks in dhcpd.conf file. */
static const unsigned int SHARED_NETWORKS = 8192;
/*! \var prefixes[2][NUM_OF_PREFIX]
* \brief ISC lease file formats for IPv4 and IPv6.
*
* The .indent.pro in use will mess formatting of array below.
* Please do not commit less readable indentation. */
static const char *prefixes[2][NUM_OF_PREFIX] = {
[VERSION_4] = {
[PREFIX_LEASE] = "lease ",
[PREFIX_BINDING_STATE_FREE] = " binding state free",
[PREFIX_BINDING_STATE_ABANDONED] = " binding state abandoned",
[PREFIX_BINDING_STATE_EXPIRED] = " binding state expired",
[PREFIX_BINDING_STATE_RELEASED] = " binding state released",
[PREFIX_BINDING_STATE_ACTIVE] = " binding state active",
[PREFIX_BINDING_STATE_BACKUP] = " binding state backup",
[PREFIX_HARDWARE_ETHERNET] = " hardware ethernet"
},
[VERSION_6] = {
[PREFIX_LEASE] = " iaaddr ",
[PREFIX_BINDING_STATE_FREE] = " binding state free",
[PREFIX_BINDING_STATE_ABANDONED] = " binding state abandoned",
[PREFIX_BINDING_STATE_EXPIRED] = " binding state expired",
[PREFIX_BINDING_STATE_RELEASED] = " binding state released",
[PREFIX_BINDING_STATE_ACTIVE] = " binding state active",
[PREFIX_BINDING_STATE_BACKUP] = " binding state backup",
[PREFIX_HARDWARE_ETHERNET] = " hardware ethernet"
}
};
#endif /* DEFAULTS_H */