comparison mercurial/revset.py @ 26099:ab66c1dee405

revset: cache smartset's min/max As the content of a smartset never changes, min and max will never change either. This will save us time when this function is called multiple times. This is relevant for issue4782 but does not fix it.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 27 Aug 2015 17:57:33 -0700
parents 6eed95ca4c03
children 5618858dce26
comparison
equal deleted inserted replaced
26098:ce26928cbe41 26099:ab66c1dee405
2883 2883
2884 def isdescending(self): 2884 def isdescending(self):
2885 """True if the set will iterate in descending order""" 2885 """True if the set will iterate in descending order"""
2886 raise NotImplementedError() 2886 raise NotImplementedError()
2887 2887
2888 @util.cachefunc
2888 def min(self): 2889 def min(self):
2889 """return the minimum element in the set""" 2890 """return the minimum element in the set"""
2890 if self.fastasc is not None: 2891 if self.fastasc is not None:
2891 for r in self.fastasc(): 2892 for r in self.fastasc():
2892 return r 2893 return r
2893 raise ValueError('arg is an empty sequence') 2894 raise ValueError('arg is an empty sequence')
2894 return min(self) 2895 return min(self)
2895 2896
2897 @util.cachefunc
2896 def max(self): 2898 def max(self):
2897 """return the maximum element in the set""" 2899 """return the maximum element in the set"""
2898 if self.fastdesc is not None: 2900 if self.fastdesc is not None:
2899 for r in self.fastdesc(): 2901 for r in self.fastdesc():
2900 return r 2902 return r