Nathan, The method name is inaccurate, right, it can be named like you want. The reason of performance boost _is_not_ in this method (nevertheless this method probably is fastest available for rounding). This method is utility and I see no point in moving it to Math.
The reason of the performance boost is: > On Fri, Apr 18, 2008 at 11:51 AM, Aleksey Shipilev <[EMAIL PROTECTED]> wrote: >> I'm pushing the idea that >> this optimization is general because it moves long-latency modulo (%) >> operations to really cheap mask (&), but to guarantee this, we should >> guarantee the storage is 2^k, where k is 0..N. Thanks, Aleksey. On Fri, Apr 18, 2008 at 9:03 PM, Nathan Beyer <[EMAIL PROTECTED]> wrote: > So the method 'roundTo2k' is incorrectly named, then? Should it be > 'roundTo2ToTheK'? Isn't there a Math method that should be used to do this, > which in turn should be the focus of optimization? I'd rather see such a > "general" optimization pushed into Math and then have all of the XHashMap > implementations use the Math methods consistently. > > -Nathan > > On Fri, Apr 18, 2008 at 11:51 AM, Aleksey Shipilev < > > [EMAIL PROTECTED]> wrote: > > > > Nathan, > > > > I think we have a sort of misunderstanding here. I'm not rounding to > > 2000, rather I round to next power of 2. I'm pushing the idea that > > this optimization is general because it moves long-latency modulo (%) > > operations to really cheap mask (&), but to guarantee this, we should > > guarantee the storage is 2^k, where k is 0..N. > > > > Thanks, > > Aleksey. > > > > On Fri, Apr 18, 2008 at 8:44 PM, Nathan Beyer <[EMAIL > PROTECTED]<https://mail.google.com/mail?view=cm&tf=0&[EMAIL PROTECTED]>> > > > > wrote: > > > I'm sure this optimization shows an improvement in the serialization > > use > > > case, but you'd be hard pressed to say that this improvement will make > > 80% > > > of all uses of HashMap, WeakHashMap and IdentityHashMap better. If you > > want > > > to round to 2000 to improve serialization, then do that in the > > > serialization. > > > > > > I don't think this should be applied as is. > > > > > > -Nathan > > > > > >
