]> git.puffer.fish Git - matthieu/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 13:10:42 +0000 (17:10 +0400)
commite1fabbb86c2558b336b83de443a4fde4b2a8db90
tree901bc9ebd8070f59f9ebdd6075e857c346f50fec
parentbf19277c341e6c1b94046c628c0e6d0f0b20d536
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