Closed josephlord closed 9 years ago
Very interesting. Thanks for pointing this out. I'll finish the port. Would this apply to Objective-C?
C type structs would be fast but don't have as good syntactic sugar as in Swift and aren't so idiomatic for Objective-C. Once you have abandoned objects it is essentially just C but that probably is the typical approach when really performance critical code is required.
Wow, performance is 100% better! Thanks for the tip.
Brutal hack and no correctness checking done.
Don’t just merge this. PR is for showing code rather than immediate merging. I haven’t got the tests running and changing to a struct point type will have changed the semantics. It does however more than double the speed of the test on my iPhone 5 from about 28s to 13.5s on my iPhone 5 for 10000 runs.
If you want high performance in Swift then structs can really deliver and given more time I would have done a more extensive rewrite changing more of you classes into structs where it made sense. The code as it stands feels like a very direct translation that doesn't utilise the full strength of Swift and in particular structs.