lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tatu Saloranta <cowtownco...@yahoo.com>
Subject Re: (byte)((i & 0x7f) | 0x80) == (byte)(i | 0x80)
Date Wed, 26 Apr 2006 21:44:22 GMT
--- Yonik Seeley <yseeley@gmail.com> wrote:

> On 4/26/06, Charlie <charliecmo@gmail.com> wrote:
> >    writeByte((byte)((i & 0x7f) | 0x80));
> >    writeByte((byte)(i | 0x80));
> 
> Yes, these two lines are equivalent.
> It's fairly likely that the JVM already does this
> optimization for you though...
> at least gcc -O already compiles to identical
> assembly for those two lines.

For many other kinds of operations it is true; HotSpot
is quite good... but for some reason, more often than
not, it does not aggressively optimize byte-shuffling
code like this. So I am not surprised that in this
particular case there is significant performance boost
(same goes for UTF-8 decoding, for example -- it's
surprising how significant gains can be gotten with
straight-forward changes).
Perhaps HotSpot folks have focused more on efficient
speculative inlining of method calls, thinking that
these low-level cases get hand-optimized well? ;-)

-+ Tatu +-



> 
> -Yonik
> http://incubator.apache.org/solr Solr, the
> open-source Lucene search server
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> java-dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail:
> java-dev-help@lucene.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message