@@ -91,7 +91,13 @@ extension Processor {
91
91
assert ( payload. quantKind == . eager
92
92
&& payload. minTrips == 0
93
93
&& payload. extraTrips == nil )
94
+ _doRunEagerZeroOrMoreQuantify ( payload)
95
+ }
94
96
97
+ // NOTE: So-as to inline into one-or-more call, which makes a significant
98
+ // performance difference
99
+ @inline ( __always)
100
+ mutating func _doRunEagerZeroOrMoreQuantify( _ payload: QuantifyPayload ) {
95
101
guard let next = _doQuantifyMatch ( payload) else {
96
102
// Consumed no input, no point saved
97
103
return
@@ -110,30 +116,21 @@ extension Processor {
110
116
savePoints. append ( makeQuantifiedSavePoint ( rangeStart..< rangeEnd, isScalarSemantics: payload. isScalarSemantics) )
111
117
}
112
118
113
- /// Specialized quantify instruction interpreter for +
119
+ /// Specialized quantify instruction interpreter for `+`
114
120
mutating func runEagerOneOrMoreQuantify( _ payload: QuantifyPayload ) -> Bool {
115
121
assert ( payload. quantKind == . eager
116
122
&& payload. minTrips == 1
117
123
&& payload. extraTrips == nil )
118
- var savePoint = startQuantifierSavePoint (
119
- isScalarSemantics: payload. isScalarSemantics
120
- )
121
- while true {
122
- let next = _doQuantifyMatch ( payload)
123
- guard let idx = next else { break }
124
- currentPosition = idx
125
- savePoint. updateRange ( newEnd: currentPosition)
126
- }
127
124
128
- if !savePoint. isQuantified {
125
+ // Match at least once
126
+ guard let next = _doQuantifyMatch ( payload) else {
129
127
signalFailure ( )
130
128
return false
131
129
}
132
- // The last save point has saved the current position, so it's unneeded
133
- savePoint. shrinkRange ( input)
134
- if savePoint. isQuantified {
135
- savePoints. append ( savePoint)
136
- }
130
+
131
+ // Run `a+` as `aa*`
132
+ currentPosition = next
133
+ _doRunEagerZeroOrMoreQuantify ( payload)
137
134
return true
138
135
}
139
136
0 commit comments