Skip to content

Commit b9b6a35

Browse files
committed
Remove unnecessary Array copy.
Array.append(contentsOf:) supports any Sequence, and String.UTF8View is a sequence, so there's no need to create an Array from it to append it. From a post-merge feedback in swiftlang#2393.
1 parent 7a3cf7f commit b9b6a35

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Foundation/JSONSerialization.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ open class JSONSerialization : NSObject {
130130
sortedKeys: opt.contains(.sortedKeys),
131131
writer: { (str: String?) in
132132
if let str = str {
133-
jsonStr.append(contentsOf: Array(str.utf8))
133+
jsonStr.append(contentsOf: str.utf8)
134134
}
135135
}
136136
)

0 commit comments

Comments
 (0)