Skip to content

Commit 60d9bf2

Browse files
committed
Removes redundant buffer zeroing
1 parent 389e84f commit 60d9bf2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

stdlib/public/Darwin/CoreGraphics/CoreGraphics.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,11 @@ extension CGColorSpace {
100100
public var colorTable: [UInt8]? {
101101
guard self.model == .indexed else { return nil }
102102
let components = self.baseColorSpace?.numberOfComponents ?? 1
103-
var table = [UInt8](repeating: 0, count: self.__colorTableCount * components)
104-
self.__unsafeGetColorTable(&table)
105-
return table
103+
let count = self.__colorTableCount * components
104+
return [UInt8](unsafeUninitializedCapacity: count) { buf, initializedCount in
105+
self.__unsafeGetColorTable(buf)
106+
initializedCount = count
107+
}
106108
}
107109
}
108110

0 commit comments

Comments
 (0)