If I have a “large” struct like
struct Vertex
{
let x:Double, y:Double
var r:Int, g:Int, b:Int
let s:Double, t:Double
var selected:Bool
}
and I want to pass it to a function without modifying it like
func taxicab_distance(_ v1:Vertex, _ v2:Vertex) -> Double
{
return v2.x - v1.x + v2.y - v1.y
}
Will the entire struct Vertex get copied and pushed onto the stack, or will
only the relevant members be passed to the function?
In other words, does the compiler know to optimize this call down to
func taxicab_distance(v2x:Double, v1x:Double, v2y:Double, v1y:Double) ->
Double
{
return v2x - v1x + v2y - v1y
}
?
_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users