New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hack point to be a struct. #7

Merged
merged 1 commit into from Mar 18, 2015

Conversation

Projects
None yet
2 participants
@josephlord
Contributor

josephlord commented Mar 18, 2015

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.

Hack point to be a struct.
Brutal hack and no correctness checking done.
@harrycheung

This comment has been minimized.

Show comment
Hide comment
@harrycheung

harrycheung Mar 18, 2015

Owner

Very interesting. Thanks for pointing this out. I'll finish the port. Would this apply to Objective-C?

Owner

harrycheung commented Mar 18, 2015

Very interesting. Thanks for pointing this out. I'll finish the port. Would this apply to Objective-C?

@josephlord

This comment has been minimized.

Show comment
Hide comment
@josephlord

josephlord Mar 18, 2015

Contributor

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.

Contributor

josephlord commented Mar 18, 2015

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.

@harrycheung harrycheung merged commit 7c918af into harrycheung:master Mar 18, 2015

@harrycheung

This comment has been minimized.

Show comment
Hide comment
@harrycheung

harrycheung Mar 18, 2015

Owner

Wow, performance is 100% better! Thanks for the tip.

Owner

harrycheung commented Mar 18, 2015

Wow, performance is 100% better! Thanks for the tip.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment