Skip to content

Commit 2b69446

Browse files
committed
wip: more refactoring
1 parent 024cc5b commit 2b69446

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

Sources/_StringProcessing/Engine/MEQuantify.swift

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,26 @@ extension Processor {
5050
mutating func runQuantify(_ payload: QuantifyPayload) -> Bool {
5151
var trips = 0
5252
var extraTrips = payload.extraTrips
53+
54+
while trips < payload.minTrips {
55+
guard let next = _doQuantifyMatch(payload) else {
56+
signalFailure()
57+
return false
58+
}
59+
currentPosition = next
60+
trips += 1
61+
}
62+
5363
var savePoint = startQuantifierSavePoint(
5464
isScalarSemantics: payload.isScalarSemantics
5565
)
56-
5766
while true {
58-
if trips >= payload.minTrips {
59-
if extraTrips == 0 { break }
60-
extraTrips = extraTrips.map({$0 - 1})
61-
if payload.quantKind == .eager {
62-
savePoint.updateRange(newEnd: currentPosition)
63-
}
67+
if extraTrips == 0 { break }
68+
extraTrips = extraTrips.map({$0 - 1})
69+
if payload.quantKind == .eager {
70+
savePoint.updateRange(newEnd: currentPosition)
6471
}
72+
6573
let next = _doQuantifyMatch(payload)
6674
guard let idx = next else {
6775
if savePoint.isQuantified {
@@ -75,11 +83,6 @@ extension Processor {
7583
trips += 1
7684
}
7785

78-
if trips < payload.minTrips {
79-
signalFailure()
80-
return false
81-
}
82-
8386
if savePoint.isQuantified {
8487
savePoints.append(savePoint)
8588
}

0 commit comments

Comments
 (0)