mirror of
				https://git.launchpad.net/~ubuntu-release/britney/+git/britney2-ubuntu
				synced 2025-11-04 10:34:05 +00:00 
			
		
		
		
	britney: Optimise the original auto-hinter a bit
Notably: * Avoid repeated calls frozenset(X), where we can trivially do without. * Skip the inner loop, when "i" is in "to_skip". * Use a set rather than a list for "to_skip" as we do more membership tests. Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
		
							parent
							
								
									be1ee0fcd3
								
							
						
					
					
						commit
						2f663fa7b9
					
				
							
								
								
									
										27
									
								
								britney.py
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								britney.py
									
									
									
									
									
								
							@ -2801,22 +2801,33 @@ class Britney(object):
 | 
			
		||||
                    if not looped and len(items) > 1:
 | 
			
		||||
                        mincands.append(items[:])
 | 
			
		||||
                    looped = True
 | 
			
		||||
                if len(items) > 1 and frozenset(items) != frozenset(mincands[-1]):
 | 
			
		||||
                if (len(items) > 1 and len(items) != len(mincands[-1]) and
 | 
			
		||||
                    frozenset(items) != frozenset(mincands[-1])):
 | 
			
		||||
                    candidates.append(items)
 | 
			
		||||
 | 
			
		||||
        for l in [ candidates, mincands ]:
 | 
			
		||||
            to_skip = []
 | 
			
		||||
            to_skip = set()
 | 
			
		||||
            for i in range(len(l)):
 | 
			
		||||
                if i in to_skip:
 | 
			
		||||
                    continue
 | 
			
		||||
                l_i = None
 | 
			
		||||
                for j in range(i+1, len(l)):
 | 
			
		||||
                    if i in to_skip or j in to_skip:
 | 
			
		||||
                    if j in to_skip:
 | 
			
		||||
                        # we already know this list isn't interesting
 | 
			
		||||
                        continue
 | 
			
		||||
                    elif frozenset(l[i]) >= frozenset(l[j]):
 | 
			
		||||
                    if l_i is None:
 | 
			
		||||
                        l_i = frozenset(l[i])
 | 
			
		||||
                    l_j = frozenset(l[j])
 | 
			
		||||
                    if l_i >= l_j:
 | 
			
		||||
                        # j is a subset of i; ignore it
 | 
			
		||||
                        to_skip.append(j)
 | 
			
		||||
                    elif frozenset(l[i]) <= frozenset(l[j]):
 | 
			
		||||
                        # i is a subset of j; ignore it
 | 
			
		||||
                        to_skip.append(i)
 | 
			
		||||
                        to_skip.add(j)
 | 
			
		||||
                    elif l_i < l_j:
 | 
			
		||||
                        # i is a subset of j; ignore it and the rest of the
 | 
			
		||||
                        # "i" series.
 | 
			
		||||
                        # NB: We use < and not <= because the "==" case is
 | 
			
		||||
                        # already covered above
 | 
			
		||||
                        to_skip.add(i)
 | 
			
		||||
                        break
 | 
			
		||||
            for i in range(len(l)):
 | 
			
		||||
                if i not in to_skip:
 | 
			
		||||
                    self.do_hint("easy", "autohinter", [ MigrationItem("%s/%s" % (x[0], x[1])) for x in l[i] ])
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user