mesonlib: specialize the implementation of == and !=

Instead of using the ___cmp__ method just straight up compare the two
values, since we've already converted numbers to ints and split
non-numeric seperators this is sufficient, and 4x faster
This commit is contained in:
Dylan Baker 2019-04-22 16:25:42 -07:00
parent 8977e49a9b
commit fa26844f67
1 changed files with 8 additions and 1 deletions

View File

@ -530,7 +530,14 @@ class Version:
return self.__cmp__(other) == -1
def __eq__(self, other):
return self.__cmp__(other) == 0
if isinstance(other, Version):
return self._v == other._v
return NotImplemented
def __ne__(self, other):
if isinstance(other, Version):
return self._v != other._v
return NotImplemented
def __cmp__(self, other):
def cmp(a, b):