Show More
@@ -2633,8 +2633,10 b' class _generatorset(abstractsmartset):' | |||
|
2633 | 2633 | if iterasc is not None: |
|
2634 | 2634 | if iterasc: |
|
2635 | 2635 | self.fastasc = self.__iter__ |
|
2636 | self.__contains__ = self._asccontains | |
|
2636 | 2637 | else: |
|
2637 | 2638 | self.fastdesc = self.__iter__ |
|
2639 | self.__contains__ = self._desccontains | |
|
2638 | 2640 | |
|
2639 | 2641 | def __nonzero__(self): |
|
2640 | 2642 | for r in self: |
@@ -2653,6 +2655,36 b' class _generatorset(abstractsmartset):' | |||
|
2653 | 2655 | self._cache[x] = False |
|
2654 | 2656 | return False |
|
2655 | 2657 | |
|
2658 | def _asccontains(self, x): | |
|
2659 | """version of contains optimised for ascending generator""" | |
|
2660 | if x in self._cache: | |
|
2661 | return self._cache[x] | |
|
2662 | ||
|
2663 | # Use new values only, as existing values would be cached. | |
|
2664 | for l in self._consumegen(): | |
|
2665 | if l == x: | |
|
2666 | return True | |
|
2667 | if l > x: | |
|
2668 | break | |
|
2669 | ||
|
2670 | self._cache[x] = False | |
|
2671 | return False | |
|
2672 | ||
|
2673 | def _desccontains(self, x): | |
|
2674 | """version of contains optimised for descending generator""" | |
|
2675 | if x in self._cache: | |
|
2676 | return self._cache[x] | |
|
2677 | ||
|
2678 | # Use new values only, as existing values would be cached. | |
|
2679 | for l in self._consumegen(): | |
|
2680 | if l == x: | |
|
2681 | return True | |
|
2682 | if l < x: | |
|
2683 | break | |
|
2684 | ||
|
2685 | self._cache[x] = False | |
|
2686 | return False | |
|
2687 | ||
|
2656 | 2688 | def __iter__(self): |
|
2657 | 2689 | if self._finished: |
|
2658 | 2690 | return iter(self._genlist) |
@@ -2707,20 +2739,6 b' class _ascgeneratorset(_generatorset):' | |||
|
2707 | 2739 | def __init__(self, gen): |
|
2708 | 2740 | super(_ascgeneratorset, self).__init__(gen, iterasc=True) |
|
2709 | 2741 | |
|
2710 | def __contains__(self, x): | |
|
2711 | if x in self._cache: | |
|
2712 | return self._cache[x] | |
|
2713 | ||
|
2714 | # Use new values only, as existing values would be cached. | |
|
2715 | for l in self._consumegen(): | |
|
2716 | if l == x: | |
|
2717 | return True | |
|
2718 | if l > x: | |
|
2719 | break | |
|
2720 | ||
|
2721 | self._cache[x] = False | |
|
2722 | return False | |
|
2723 | ||
|
2724 | 2742 | class _descgeneratorset(_generatorset): |
|
2725 | 2743 | """Wrap a generator of descending elements for lazy iteration |
|
2726 | 2744 | |
@@ -2734,20 +2752,6 b' class _descgeneratorset(_generatorset):' | |||
|
2734 | 2752 | def __init__(self, gen): |
|
2735 | 2753 | super(_descgeneratorset, self).__init__(gen, iterasc=False) |
|
2736 | 2754 | |
|
2737 | def __contains__(self, x): | |
|
2738 | if x in self._cache: | |
|
2739 | return self._cache[x] | |
|
2740 | ||
|
2741 | # Use new values only, as existing values would be cached. | |
|
2742 | for l in self._consumegen(): | |
|
2743 | if l == x: | |
|
2744 | return True | |
|
2745 | if l < x: | |
|
2746 | break | |
|
2747 | ||
|
2748 | self._cache[x] = False | |
|
2749 | return False | |
|
2750 | ||
|
2751 | 2755 | def spanset(repo, start=None, end=None): |
|
2752 | 2756 | """factory function to dispatch between fullreposet and actual spanset |
|
2753 | 2757 |
General Comments 0
You need to be logged in to leave comments.
Login now