diff -r 47618b00405b Tools/clinic/clinic.py --- a/Tools/clinic/clinic.py Sat Oct 19 10:45:48 2013 +0300 +++ b/Tools/clinic/clinic.py Sat Oct 19 20:28:11 2013 +0300 @@ -138,12 +138,7 @@ return s def rstrip_lines(s): - text, add, output = _text_accumulator() - for line in s.split('\n'): - add(line.rstrip()) - add('\n') - text.pop() - return output() + return '\n'.join(line.rstrip() for line in s.split('\n')) def linear_format(s, **kwargs): """ @@ -268,11 +263,11 @@ def permute_left_option_groups(l): """ - Given [1, 2, 3], should yield: + Given [[1, 2], [3, 4], [5, 6]], should yield: () - (3,) - (2, 3) - (1, 2, 3) + (5, 6,) + (3, 4, 5, 6) + (1, 2, 3, 4, 5, 6) """ yield tuple() accumulator = [] @@ -283,11 +278,11 @@ def permute_right_option_groups(l): """ - Given [1, 2, 3], should yield: + Given [[1, 2], [3, 4], [5, 6]], should yield: () - (1,) (1, 2) - (1, 2, 3) + (1, 2, 3, 4) + (1, 2, 3, 4, 5, 6) """ yield tuple() accumulator = [] @@ -307,23 +302,19 @@ If required is empty, left must also be empty. """ required = tuple(required) - result = [] if not required: assert not left - accumulator = [] - counts = set() + d = {} + plog = tuple(permute_left_option_groups(left)) for r in permute_right_option_groups(right): - for l in permute_left_option_groups(left): + for l in plog: t = l + required + r - if len(t) in counts: - continue - counts.add(len(t)) - accumulator.append(t) - - accumulator.sort(key=len) - return tuple(accumulator) + if len(t) not in d: + d[len(t)] = t + + return tuple(sorted(d.values(), key=len)) class CLanguage(Language):