Skip to content

Commit 31af226

Browse files
committed
Simplify iteration in batch generator
1 parent fcf170d commit 31af226

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

src/draw.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -188,19 +188,7 @@ function* streamBatchedDrawablePatterns({
188188
patterns: [],
189189
}
190190

191-
while (true) {
192-
const iteratorResult = drawQueueIterator.next()
193-
194-
if (iteratorResult.done) {
195-
if (chunk.patterns.length > 0) {
196-
yield chunk
197-
}
198-
199-
break
200-
}
201-
202-
const entry = iteratorResult.value
203-
191+
for (const entry of drawQueueIterator) {
204192
if (chunk.depth !== entry.depth) {
205193
if (chunk.patterns.length > 0) {
206194
yield chunk
@@ -212,7 +200,6 @@ function* streamBatchedDrawablePatterns({
212200
}
213201
} else {
214202
chunk.patterns.push(entry.currentPattern)
215-
}
216203

217204
if (chunk.patterns.length >= chunkSize) {
218205
yield chunk
@@ -221,6 +208,11 @@ function* streamBatchedDrawablePatterns({
221208
patterns: [],
222209
}
223210
}
211+
}
212+
}
213+
214+
if (chunk.patterns.length > 0) {
215+
yield chunk
224216
}
225217
}
226218

0 commit comments

Comments
 (0)