Skip to content

Commit c5fc1e3

Browse files
author
Itai Ferber
committed
Use encode(contentsOf:) instead of a loop
1 parent c6f8834 commit c5fc1e3

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

stdlib/public/SDK/Foundation/Codable.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ extension Data : Codable {
5959
var caughtError: Error? = nil
6060
self.enumerateBytes { (buffer: UnsafeBufferPointer<UInt8>, byteIndex: Data.Index, stop: inout Bool) in
6161
do {
62-
for byte in buffer {
63-
try bytesContainer.encode(byte)
64-
}
62+
try bytesContainer.encode(contentsOf: buffer)
6563
} catch {
6664
caughtError = error
6765
stop = true

0 commit comments

Comments
 (0)