Skip to content

Commit e83dc07

Browse files
committed
Optimize Entry.plainText concatenation
1 parent 481f3eb commit e83dc07

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Sources/Rainbow.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,12 @@ public enum Rainbow {
8585
}
8686

8787
public var plainText: String {
88-
return segments.reduce("") { $0 + $1.text }
88+
var result = String()
89+
result.reserveCapacity(segments.reduce(0) { $0 + $1.text.utf8.count })
90+
for segment in segments {
91+
result.append(segment.text)
92+
}
93+
return result
8994
}
9095

9196
public var isPlain: Bool {

0 commit comments

Comments
 (0)