-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix/capturedvars #354
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
Fix/capturedvars #354
Conversation
Create an object Util for utility methods that are used in several places.
I accidentally slipped another change into this PR (Make line search logic in SourcePositions generally available). But that's OK. We want to do that anyway. |
b15d4e5
to
b6efacf
Compare
* as the first search point, otherwise use | ||
* `candidates.length/2`. | ||
* @pre candidates is sorted | ||
* @pre candidates(0) <= x |
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.
The second precondition should not be there, since you specify what happens if it's not true, i.e., the method must return -1. (as opposed to: it crashes or loops indefinitely)
That's all I have. LGTM for the commit about the mutable flag. |
Thanks for the quick review! |
if (x < candidates(mid)) | ||
recur(lo, mid - 1, (lo + mid - 1) / 2) | ||
else if (mid + 1 < candidates.length && x >= candidates(mid + 1)) | ||
recur(mid + 1, hi, (mid + 1 + hi) / 2) |
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.
This is prone to overflow (http://googleresearch.blogspot.com.au/2006/06/extra-extra-read-all-about-it-nearly.html).
Of course we're unlikely to deal with a source file long enough to hit the problem :)
Backport "improvement: Support using directives in worksheets" to 3.3 LTS
Review by @sjrd