Skip to content

Commit 2270425

Browse files
committed
Fix compilation w/ older compilers
1 parent a898009 commit 2270425

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/String+Utils.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ internal extension String {
6565

6666
var hasProcessedNewLines = false
6767
var specialCharState: (UnicodeScalar, Int)? = nil /* First element is the special char, the other is the number of octothorps found. */
68-
let ascii = unicodeScalars.lazy.map{ scalar in
68+
let ascii = unicodeScalars.lazy.map{ scalar -> String in
6969
/* Let’s build the previous escape if needed. */
7070
let prefix: String
7171
if scalar == "#" {
@@ -115,7 +115,9 @@ internal extension String {
115115
return prefix + (octothorpLevel == 0 ? escaped : escaped.replacingOccurrences(of: #"\"#, with: #"\"# + octothorps, options: .literal))
116116
}
117117
}
118-
return (sepOpen + ascii.joined(separator: "") + (specialCharState.flatMap{ String($0.0) + String(repeating: "#", count: $0.1) } ?? "") + sepClose, hasProcessedNewLines)
118+
let asciiJoined = ascii.joined(separator: "")
119+
let specialCharStateMapped = (specialCharState.flatMap{ String($0.0) + String(repeating: "#", count: $0.1) } ?? "")
120+
return (sepOpen + asciiJoined + specialCharStateMapped + sepClose, hasProcessedNewLines)
119121
}
120122

121123
private static let newLines = CharacterSet.newlines

0 commit comments

Comments
 (0)