Skip to content

Commit 165e8b0

Browse files
committed
Uses reduce(into:,_) instead of reduce(_,_)` to avoid intermediate arrays allocations
1 parent 1755bd0 commit 165e8b0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Sources/CryptoSwift/SHA3.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ extension SHA3: Updatable {
275275
self.accumulated.removeFirst(processedBytes)
276276

277277
// TODO: verify performance, reduce vs for..in
278-
let result = self.accumulatedHash.reduce(Array<UInt8>()) { (result, value) -> Array<UInt8> in
279-
result + value.bigEndian.bytes()
278+
let result = self.accumulatedHash.reduce(into: Array<UInt8>()) { (result, value) in
279+
result += value.bigEndian.bytes()
280280
}
281281

282282
// reset hash value for instance

0 commit comments

Comments
 (0)