--- Yonik Seeley <[EMAIL PROTECTED]> wrote: > On 4/26/06, Charlie <[EMAIL PROTECTED]> 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: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]