Re: (byte)((i & 0x7f) | 0x80) == (byte)(i | 0x80)

2006-04-26 Thread Tatu Saloranta
--- 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.

Re: Re[2]: (byte)((i & 0x7f) | 0x80) == (byte)(i | 0x80)

2006-04-26 Thread Yonik Seeley
On 4/26/06, Marvin Humphrey <[EMAIL PROTECTED]> wrote: > So the question is, does this assertion hold? > > (byte)((i & 0x7f) | 0x80) == (byte)(i | 0x80) Yes. I tested just this out, and java5 -server reports a 15% performance boost for writeVInt alone, tested over number

Re: (byte)((i & 0x7f) | 0x80) == (byte)(i | 0x80)

2006-04-26 Thread Yonik Seeley
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 f

Re: Re[2]: (byte)((i & 0x7f) | 0x80) == (byte)(i | 0x80)

2006-04-26 Thread Marvin Humphrey
code, would not be changing. So the question is, does this assertion hold? (byte)((i & 0x7f) | 0x80) == (byte)(i | 0x80) Marvin Humphrey Rectangular Research http://www.rectangular.com/ - To unsubscribe, e-mail: [E

Re: Re[2]: (byte)((i & 0x7f) | 0x80) == (byte)(i | 0x80)

2006-04-26 Thread Yonik Seeley
On 4/26/06, Charlie <[EMAIL PROTECTED]> wrote: > ok, thanks for your reply. > > But I thought > Method: public void writeVInt(int i) > is not about UTF-8, it is about how to write an int in variable length. Oh, sorry... wrong function. It was a similar optimization to things I had seen in the cha

Re[2]: (byte)((i & 0x7f) | 0x80) == (byte)(i | 0x80)

2006-04-26 Thread Charlie
ok, thanks for your reply. But I thought Method: public void writeVInt(int i) is not about UTF-8, it is about how to write an int in variable length. Is it included as a part of future unicode character writing? -- Best regards, Charlie --- >> I thought >> >> (byte)

Re: (byte)((i & 0x7f) | 0x80) == (byte)(i | 0x80)

2006-04-26 Thread Yonik Seeley
On 4/26/06, Charlie <[EMAIL PROTECTED]> wrote: > I thought > > (byte)((i & 0x7f) | 0x80) == (byte)(i | 0x80) > > As (byte) is able to truncate the last byte for us already, no need of > (& 0x7f). If so, we may change that line to > >writeByte((byte)(i |

(byte)((i & 0x7f) | 0x80) == (byte)(i | 0x80)

2006-04-26 Thread Charlie
Hello, In: public abstract class IndexOutput public void writeVInt(int i) writeByte((byte)((i & 0x7f) | 0x80)); I thought (byte)((i & 0x7f) | 0x80) == (byte)(i | 0x80) As (byte) is able to truncate the last byte for us already, no need of (& 0x7f). If so, we may change