* 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 a33c34964a473da431b650176cd6eeb5388fc67d..ea243f9507e434d6e8b6b1e5cd0b2eac30756956 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