Skip to content

Commit 4d2caff

Browse files
committed
reduce: try to reduce blocks better
1 parent ef1dd89 commit 4d2caff

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

tools/reduce.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,17 @@ def removeblocks(filedata):
178178

179179
i2 = i1
180180
indent = 0
181-
while i2 < len(filedata):
181+
while i2 < len(filedata) and indent>=0:
182182
for c in filedata[i2]:
183183
if c == '}':
184184
indent = indent - 1
185-
if indent <= 0:
186-
break
185+
if indent == 0:
186+
indent = -100
187187
elif c == '{':
188188
indent = indent + 1
189189
i2 = i2 + 1
190+
if indent == -100:
191+
indent = 0
190192
if i2 == i1 or i2 >= len(filedata):
191193
continue
192194
if filedata[i2].strip() != '}' and filedata[i2].strip() != '};':

0 commit comments

Comments
 (0)