RFR(S): 8007986: GrowableArray should implement binary search

John Rose john.r.rose at oracle.com
Fri Feb 12 00:24:00 UTC 2016


The uint cast version might optimize better which is why I didn't suggest the half-difference idiom. 

And also this should be a macro or function in globalDefinitions.hpp

Life is too short to rediscover correct C expression semantics at every use point. 

– John

> On Feb 11, 2016, at 3:48 PM, Vitaly Davidovich <vitalyd at gmail.com> wrote:
> 
> Perhaps
> 
> mid = min + (max - min)/2
> 
> is better?
> 
>> On Thursday, February 11, 2016, John Rose <john.r.rose at oracle.com> wrote:
>>> On Feb 11, 2016, at 4:46 AM, Roland Westrelin <roland.westrelin at oracle.com> wrote:
>>> 
>>> overflow issue in the binary search 
>> 
>> The outer parens look wrong on the fix.  You want to cast to int *after* dividing by two, I think.
>> 
>> — John
> 
> 
> -- 
> Sent from my phone
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20160211/45aadcbe/attachment.html>


More information about the hotspot-compiler-dev mailing list