@@ -434,10 +434,9 @@ private func check(input b : String, against checkStrings : [CheckString]) -> Bo
434
434
435
435
var i = 0
436
436
var j = 0
437
- var e = checkStrings. count
438
437
while true {
439
438
var checkRegion : String
440
- if j == e {
439
+ if j == checkStrings . count {
441
440
checkRegion = buffer
442
441
} else {
443
442
let checkStr = checkStrings [ j]
@@ -452,7 +451,6 @@ private func check(input b : String, against checkStrings : [CheckString]) -> Bo
452
451
return false
453
452
}
454
453
455
-
456
454
checkRegion = buffer. substring ( to: buffer. index ( buffer. startIndex, offsetBy: NSMaxRange ( range) ) )
457
455
buffer = buffer. substring ( from: buffer. index ( buffer. startIndex, offsetBy: NSMaxRange ( range) ) )
458
456
j += 1
@@ -472,7 +470,7 @@ private func check(input b : String, against checkStrings : [CheckString]) -> Bo
472
470
checkRegion = checkRegion. substring ( from: checkRegion. index ( checkRegion. startIndex, offsetBy: NSMaxRange ( range) ) )
473
471
}
474
472
475
- if j == e {
473
+ if j == checkStrings . count {
476
474
break
477
475
}
478
476
}
@@ -980,18 +978,19 @@ private struct CheckString {
980
978
981
979
/// Match check string and its "not strings" and/or "dag strings".
982
980
func check( _ buffer : String , _ isLabelScanMode : Bool , _ variableTable : BoxedTable ) -> NSRange ? {
983
- var lastPos = 0
984
-
985
- // IsLabelScanMode is true when we are scanning forward to find CHECK-LABEL
981
+ // This condition is true when we are scanning forward to find CHECK-LABEL
986
982
// bounds we have not processed variable definitions within the bounded block
987
- // yet so cannot handle any final CHECK-DAG yetthis is handled when going
983
+ // yet so cannot handle any final CHECK-DAG yet this is handled when going
988
984
// over the block again (including the last CHECK-LABEL) in normal mode.
985
+ let lastPos : Int
989
986
if !isLabelScanMode {
990
987
// Match "dag strings" (with mixed "not strings" if any).
991
988
guard let lp = self . checkDAG ( buffer, variableTable) else {
992
989
return nil
993
990
}
994
991
lastPos = lp
992
+ } else {
993
+ lastPos = 0
995
994
}
996
995
997
996
// Match itself from the last position after matching CHECK-DAG.
@@ -1166,12 +1165,9 @@ private struct CheckString {
1166
1165
// PrintCheckFailed(SM, Pat.getLoc(), Pat, MatchBuffer, VariableTable)
1167
1166
return nil
1168
1167
}
1169
- var matchPos = range. location
1170
- let matchLen = range. length
1171
-
1168
+
1172
1169
// Re-calc it as the offset relative to the start of the original string.
1173
- matchPos += startPos
1174
-
1170
+ var matchPos = range. location + startPos
1175
1171
if !notStrings. isEmpty {
1176
1172
if matchPos < lastPos {
1177
1173
// Reordered?
@@ -1207,7 +1203,7 @@ private struct CheckString {
1207
1203
}
1208
1204
1209
1205
// Update the last position with CHECK-DAG matches.
1210
- lastPos = max ( matchPos + matchLen , lastPos)
1206
+ lastPos = max ( matchPos + range . length , lastPos)
1211
1207
}
1212
1208
1213
1209
return lastPos
0 commit comments