-
Notifications
You must be signed in to change notification settings - Fork 190
CellUnionFromDifference: Optimize #252
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
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| // cellUnionDifferenceInternal adds (xid - y) to the CellUnion. It subdivides | ||
| // xid when there is partial overlap, narrowing y before recursing. | ||
| func (cu *CellUnion) cellUnionDifferenceInternal(xid CellID, y CellUnion) { |
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 moved this prior to the exported method to match C++ and have better proximity.
| var cu CellUnion | ||
| for _, xid := range x { | ||
| cu.cellUnionDifferenceInternal(xid, &y) | ||
| cu.cellUnionDifferenceInternal(xid, y) |
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.
It seemed OK to pass by value
| return | ||
| } | ||
|
|
||
| y = y[lo:hi] |
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.
By reducing the size of "y" we're narrowing the search in the call to "ContainsCellID" and in recursive calls.
|
Are there benchmarks for this? |
Title explains, I'll include comment(s) in the diff. I think this is correct (?) and tried to expand the tests as well, but please let me know if you see any issues.