* libs/core/ip: save a redundant object in compare()
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 7 Aug 2008 15:39:52 +0000 (15:39 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 7 Aug 2008 15:39:52 +0000 (15:39 +0000)
libs/core/luasrc/ip.lua

index a33c349..ea243f9 100644 (file)
@@ -321,8 +321,10 @@ function cidr.mask( self, bits )
 end
 
 function cidr.contains( self, addr )
-       if self:mask() <= addr:mask() then
-               return self:mask(addr:prefix()) == addr:mask()
+       local mask1 = self:mask()
+       local mask2 = addr:mask()
+       if mask1 <= mask2 then
+               return self:mask(addr:prefix()) == mask2
        end
 
        return false