<div dir="ltr"><div><div><font face="monospace,monospace">If I have a “large” struct like<br><br>struct Vertex<br>{<br>    let x:Double, y:Double<br>    var r:Int, g:Int, b:Int<br>    let s:Double, t:Double<br>    var selected:Bool<br>}<br><br></font></div><div><font face="monospace,monospace">and I want to pass it to a function without modifying it like<br></font></div><div><font face="monospace,monospace"><br>func taxicab_distance(_ v1:Vertex, _ v2:Vertex) -&gt; Double<br>{<br>    return v2.x - v1.x + v2.y - v1.y<br>}<br><br></font></div><div><font face="monospace,monospace">Will the entire struct Vertex get copied and pushed onto the stack, or will only the relevant members be passed to the function?<br><br></font></div><div><font face="monospace,monospace">In other words, does the compiler know to optimize this call down to<br><br></font><font face="monospace,monospace">func taxicab_distance(v2x:Double, v1x:Double, v2y:Double, v1y:Double) -&gt; Double<br>{<br>    return v2x - v1x + v2y - v1y<br>}<br><br>?<br></font></div></div></div>