]> git.kaiwu.me - haproxy.git/commit
OPTIM: tools/str2net: only duplicate the string when a slash is present
authorWilly Tarreau <w@1wt.eu>
Mon, 3 Aug 2026 07:52:58 +0000 (09:52 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 3 Aug 2026 08:10:31 +0000 (10:10 +0200)
commit9bc6c4d18c2ea9836c171977c1c7c2979ecbb132
tree2f93012f62fda52bb6fe942c6012e032a94d4205
parent35560e3ad3306ac8b83db1062b18a8713b90e99e
OPTIM: tools/str2net: only duplicate the string when a slash is present

The str2net() and str62net() functions systematically strdup() the
input pattern before parsing it, while this is only needed when a '/'
is present. Given that this '/' is already looked up, better move the
allocation inside that block so that no allocation is performed when
none is present.

Doing so saves ~5% load time on plain IPv4 addresses and ~8% on plain
IPv6 addresses, while not changing anything for addresses with masks.
src/tools.c