From: Luke Kenneth Casson Leighton Date: Sat, 10 Sep 2022 14:07:37 +0000 (+0100) Subject: whitespace cleanup X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=13d7c9ca7d719523b588c03826fa7b62dbbd7f01;p=openpower-isa.git whitespace cleanup --- diff --git a/src/openpower/decoder/quine.py b/src/openpower/decoder/quine.py index 72c308b2..4c9c209e 100644 --- a/src/openpower/decoder/quine.py +++ b/src/openpower/decoder/quine.py @@ -3,28 +3,28 @@ def collapse(patterns): """Reduce patterns into compact dash notation""" - newPatterns = [] #reduced patterns - matched = [] #indexes with a string that was already matched - for x,p1 in enumerate(patterns): #pattern1 - if x in matched: continue #skip if this pattern already matched - for y,p2 in enumerate(patterns[x+1:],1): - if x+y in matched: continue #skip if this pattern already matched - diffs=0 # number of differences found - for idx,bit in enumerate(zip(p1,p2)): - if bit[0] != bit [1]: # count of bits that are different + newPatterns = [] # reduced patterns + matched = [] # indexes with a string that was already matched + for x, p1 in enumerate(patterns): # pattern1 + if x in matched: continue # skip if this pattern already matched + for y, p2 in enumerate(patterns[x+1:], 1): + if x+y in matched: continue # skip if this pattern already matched + diffs = 0 # number of differences found + for idx, bit in enumerate(zip(p1, p2)): + if bit[0] != bit[1]: # count of bits that are different diffs += 1 - dbit = idx - if diffs >1:break + dbit = idx + if diffs > 1: break # if exactly 1 bit different between the two, # they can be compressed together if diffs == 1: - newPatterns.append(p1[:dbit]+'-'+p1[dbit+1:]) + newPatterns.append('-'.join([p1[:dbit], p1[dbit+1:]])) matched+=[x,x+y] break # if the pattern wasn't matched, just append it as is. if x not in matched: newPatterns.append(p1) - # if reductions occured on this run, then call again + # if reductions occurred on this run, then call again # to check if more are possible. if matched: newPatterns = collapse(newPatterns)