Skip to content

Commit 656c388

Browse files
committed
Remove an unnecessary end check
1 parent 5114ea4 commit 656c388

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Sources/_StringProcessing/Engine/MEBuiltins.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ extension String {
190190
limitedBy end: String.Index,
191191
isScalarSemantics: Bool
192192
) -> QuickResult<String.Index?> {
193-
guard currentPosition < end else { return .definite(nil) }
193+
assert(currentPosition < end)
194194
guard let (asciiValue, next, isCRLF) = _quickASCIICharacter(
195195
at: currentPosition, limitedBy: end
196196
) else {
@@ -273,7 +273,7 @@ extension String {
273273
isStrictASCII: Bool,
274274
isScalarSemantics: Bool
275275
) -> QuickResult<String.Index?> {
276-
guard currentPosition < end else { return .definite(nil) }
276+
assert(currentPosition < end)
277277
guard let (next, result) = _quickMatch(
278278
cc,
279279
at: currentPosition,
@@ -336,7 +336,7 @@ extension String {
336336
if isScalarSemantics {
337337
matched = scalar.isNewline && asciiCheck
338338
if matched && scalar == "\r"
339-
&& next != end && unicodeScalars[next] == "\n" {
339+
&& next < end && unicodeScalars[next] == "\n" {
340340
// Match a full CR-LF sequence even in scalar semantics
341341
unicodeScalars.formIndex(after: &next)
342342
}

0 commit comments

Comments
 (0)