Skip to content

Commit fbab103

Browse files
committed
[Backtracing] Use reserveCapacity to optimize escaping slightly.
We know we need at least as much space as the number of UTF-8 characters. rdar://121430255
1 parent 583a2f8 commit fbab103

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

stdlib/public/libexec/swift-backtrace/Utils.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ func escapeJSON(_ s: String) -> String {
264264
var pos = chunk
265265
let end = utf8View.endIndex
266266

267+
result.reserveCapacity(utf8View.count)
268+
267269
while pos != end {
268270
let scalar = utf8View[pos]
269271
switch scalar {

0 commit comments

Comments
 (0)