-
Notifications
You must be signed in to change notification settings - Fork 18
Refine positions during AST traversal to reduce search space #84
Conversation
garobrik
left a comment
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.
LGTM
| }) | ||
|
|
||
| end := start | ||
| for end < len(positions) && positions[end] <= node.End() { |
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.
perf nit since it's a perf PR:
finding end would be faster using another application of sort.Search, but idk how many positions an ast node can span for whether it matters
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.
My assumption is that it's fairly small and I don't want to break cache locality here.
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.
makes sense
We do binary search on all positions for a package, which is unnecessary. As we traverse the AST we can only pass along the positions which are valid for the parent (children necessarily fall in the same bounds).