4 ms·
I've posted this response: http://blog.human-friendly.com/the-importance-of-being-final http://blog.human-friendly.com/the-importance-of-being-final Separately
by josephlord 12y ago
I've posted this response: http://blog.human-friendly.com/the-importance-of-being-final http://blog.human-friendly.com/the-importance-of-being-final
Separately I got excellent optimised performance with a final class and this renderWeirdGraphics method which outperforms the Objective-C version by 40% in optimised builds:
func renderWeirdGradient(blueOffset: Int, _ greenOffset: Int) {
let height = buffer.height
let width = buffer.width
buffer.pixels.withUnsafeMutableBufferPointer { pixels->() in
for y in 0..<height {
let row = y * width
for x in 0..<width {
let i = row + x
pixels[i].green = Byte((y + greenOffset) & 0xFF)
pixels[i].blue = Byte((x + blueOffset) & 0xFF)
}
}
}
self.needsDisplay = true
}