-
Notifications
You must be signed in to change notification settings - Fork 4
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
Make location a struct #43
Conversation
63ef5df
to
72fbca5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not do this. This will allow users to update a Location without us having any control on the values set. Today one can only create a location by invoking the factory method NewLocation which makes it very clear where values are set.
Users cannot update the fields outside of the nextroute package. type Location struct {
longitude float64
latitude float64
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as the properties of Location are not exported. Would be nice if this PR is actually also leveraging this change in the nextroute code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🌮
@davidrijsman can you elaborate a bit what you mean? |
…ute into ds/perf/location-struct
We store the valid state on the location itself. This cost 8 bytes but we get faster performance.
For now I leave the size of the struct as is. It appears that this is the faster approach during the search as most time is spent on validating locations. We can revisit that later. |
This improves efficiency by making the location a struct and also reduce its size (8 fewer bytes). This has likely some effect on the whole search as we consume fewer bytes on an object that gets copied billions of time which decreases the time it takes to check for a valid location (among other things).
The main changes are:
convT
allocation unexpectedly somewhereNaN
in thefloat64
fields.This PR also improves the performance of
Unique
andCentroid
Benchmarks (only for checking if a location is valid):
In addition most operations on locations can now be inlined.
In theory this is a breaking change but the API stays the same.