Containerization: Reduce allocations for image subsystems (#152)

Continue the allocations journey for anything that is in the codepaths
for pulling images. This time there's a couple spots in archive and ext4
we can get rid of some copies.
This commit is contained in:
Danny Canter
2025-06-18 16:11:46 -07:00
committed by GitHub
parent 35a821f041
commit 1992cfe779
3 changed files with 23 additions and 8 deletions
+4 -4
View File
@@ -101,9 +101,9 @@ extension ArchiveReader: Sequence {
internal func readDataForEntry(_ entry: WriteEntry) -> Data {
let bufferSize = Int(Swift.min(entry.size ?? 4096, 4096))
var data = Data()
var entry = Data()
var part = Data(count: bufferSize)
while true {
var part = Data(count: bufferSize)
let c = part.withUnsafeMutableBytes { buffer in
guard let baseAddress = buffer.baseAddress else {
return 0
@@ -112,9 +112,9 @@ extension ArchiveReader: Sequence {
}
guard c > 0 else { break }
part.count = c
data.append(part)
entry.append(part)
}
return data
return entry
}
}