> On May 6, 2017, at 10:39 PM, Brent Royal-Gordon <br...@architechies.com> 
> wrote:
> 
>> On May 6, 2017, at 10:34 PM, Daniel Dunbar via swift-users 
>> <swift-users@swift.org <mailto:swift-users@swift.org>> wrote:
>> 
>> To answer Kelvin's question, yes, the optimizer will be able to see through 
>> that code _assuming_ it can see the definition in a way it can optimize
> 
> 
> Kelvin, you should definitely take Daniel's word over mine on whether there's 
> an optimization for this. I believe the rest of my explanation is correct.

Actually I think yours was more accurate... while it is is true the desired 
optimization will often take effect (given the conditions I describe), your's 
was correct that this isn't happening because the function signature is taking 
_fewer_ arguments. Rather, the optimizations works because the compiler will 
tend to inline that small function and then see it can discard the unnecessary 
data.

Whether or not this makes it worth boxing your struct to avoid large copies 
probably depends on how much you need to pass the struct through call sites 
which would in fact need to copy the full struct, versus inlining down to 
something smaller.

HTH,
 - Daniel

> 
> -- 
> Brent Royal-Gordon
> Architechies
> 

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to