buildasaurs / XcodeServerSDK

Access Xcode Server API with native Swift objects.
MIT License
399 stars 30 forks source link

Use `final` to aid compiler optimizations #53

Closed cojoj closed 9 years ago

cojoj commented 9 years ago

I know I've been fighting like a lot for changing classes into structs but @czechboy0 persuaded me that there is sense in making XcodeServerEntity as class. My main argument was:

Let's make compiler happy...

So today, I've came with solution how to marry class with my happy compiler thing - let's mark some methods, properties, classes as final as they probably won't be inherited more times. Let me know if that make sense to you.

czechboy0 commented 9 years ago

So what compiler warning are you seeing? Or what do you mean thatt he compiler isn't happy right now?

cojoj commented 9 years ago

No warnings, everything's fine... By making compiler happy I mean providing source code that can be optimized by it. If we mark things as final compiler will know that there will be no more puzzles with this thing 😉 Apple has stated this sometime, somewhere but I really can't find this right now... 😕

czechboy0 commented 9 years ago

Yeah, I went to a session at WWDC where they explained that they don't have to use dynamic dispatch for final methods, instead they can just use direct memory jump.

To be honest, at the orders of magnitude we're talking about here, I don't think it makes sense for us to jump through hoops like this. For internal and private methods, if we turn of something called full module optimizations or something like that, the compiler will be able to automatically add final to most methods. We should probably find the exact WWDC session where they describe this.

My two cents: let's not add final manually anywhere yet, let's look at how we can help it do this automatically. This could turn into a primal example of premature optimization :wink: But thanks for bringing it up, @cojoj, we should always think about the best possible performance!

czechboy0 commented 9 years ago

Ok I found it. It's called Whole Module Optimization and the video is here: https://developer.apple.com/videos/wwdc/2015/?id=409

czechboy0 commented 9 years ago

Let me know if you have anything else here, otherwise I'll close it.

cojoj commented 9 years ago

No, you can close this issue - I think we're set 😉