Isn’t the compiler being a bit pedantic here, and perhaps generating less-performant code?
extension
SCNQuaternion
{
public
init(_ inQuat: CMQuaternion)
{
self.x = Float(inQuat.x) // Initializer for struct 'SCNVector4' must use "self.init(...)" or "self = ..." because the struct was imported from C
self.y = Float(inQuat.y)
self.z = Float(inQuat.z)
self.w = Float(inQuat.w)
}
SCNVector4
looks like:
public struct SCNVector4 {
public var x: Float
public var y: Float
public var z: Float
public var w: Float
public init()
public init(x: Float, y: Float, z: Float, w: Float)
}
Isn't my initializer complete? This struct can exist in some pretty tight loops (theoretically, probably not this specific instance), and zeroing out the struct first is a waste of time.
The optimizer might see that and remove that code, especially if it first inlines the call to super.init()
, but it seems Swift is being a little aggressive here.