Skip to content

Commit 018dcdd

Browse files
committed
Remove potentially expensive filter if argument list is long
1 parent 1115009 commit 018dcdd

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -508,18 +508,21 @@ extension Driver {
508508
continue
509509
} else if char.isWhitespace && !quoted {
510510
// This is unquoted, unescaped whitespace, start a new token.
511-
tokens.append(token)
512-
token = ""
511+
if !token.isEmpty {
512+
tokens.append(token)
513+
token = ""
514+
}
513515
continue
514516
}
515517

516518
token.append(char)
517519
}
518520
// Add the final token
519-
tokens.append(token)
521+
if !token.isEmpty {
522+
tokens.append(token)
523+
}
520524

521-
// Filter any empty tokens that might be parsed if there's excessive whitespace.
522-
return tokens.filter { !$0.isEmpty }
525+
return tokens
523526
}
524527

525528
/// Tokenize each line of the response file, omitting empty lines.

0 commit comments

Comments
 (0)