We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 389e84f commit 60d9bf2Copy full SHA for 60d9bf2
stdlib/public/Darwin/CoreGraphics/CoreGraphics.swift
@@ -100,9 +100,11 @@ extension CGColorSpace {
100
public var colorTable: [UInt8]? {
101
guard self.model == .indexed else { return nil }
102
let components = self.baseColorSpace?.numberOfComponents ?? 1
103
- var table = [UInt8](repeating: 0, count: self.__colorTableCount * components)
104
- self.__unsafeGetColorTable(&table)
105
- return table
+ let count = self.__colorTableCount * components
+ return [UInt8](unsafeUninitializedCapacity: count) { buf, initializedCount in
+ self.__unsafeGetColorTable(buf)
106
+ initializedCount = count
107
+ }
108
}
109
110
0 commit comments