]> git.puffer.fish Git - mirror/frr.git/commit
lib: optimize ip_masklen()
authorDenis Ovsienko <infrastation@yandex.ru>
Sun, 4 Dec 2011 19:21:55 +0000 (23:21 +0400)
committerDenis Ovsienko <infrastation@yandex.ru>
Mon, 2 Jan 2012 14:23:24 +0000 (18:23 +0400)
commitd171bf58ef12ace43d48565e6870722dece1e6ed
tree2cdd66f99933f4e0f0d175ce31599cbb6cbb981f
parent8c7f49d27767886b3706dfca11c1e13abeab7c63
lib: optimize ip_masklen()

The new implementation makes use of a 64KB mapping table, which makes it
possible to compute masklen faster and with constant execution time. The
map also allows for additional version of the function, which can detect
errors in input argument.

The previous implementation had a variable cost of execution, which
depended on masklen in a non-linear manner, and at its worst (/31) was
4 times slower, than the new implementation. The only case of old
function just slightly outperforming the new one is /0, which is of
little practical interest.
lib/prefix.c