[ExtractStream] More Re: its in the 3s.....

Dale Reed daler at n...
Mon, 19 Nov 2001 10:44:08 -0800


Ken Hancock wrote:

> --- In ExtractStream@y..., Dale Reed <daler@n...> wrote:
> > > > From Tyconvert:
> > > >
> > > > unsigned long size = (((p[0]<<8) | p[1])<<4) | (p[2]>>4);


ES .03:

> > > size = ((*p)[0]<<12 | (*p)[1])<<4 | ((*p)[2]>>4);

^---------------------^


> I'm not rusty on bit shifting -- I do it every day. Tyconvert uses << 8 
> on p[0]
> then << 4 on BOTH p[0] and p[1] which is equivalent to << 12 on p[0]. Both
> ES and TyConvert are the same -- people just misread the parentheses.
> 
> It's either a matter of programming style or the author thought that his
> version was an optimization by doing the shift as a multiple of 8. On 
> the PPC,
> however, I believe any shift operation of any size is the same number of 
> clock
> cycles, so it doesn't matter -- you still have 2 OR and 3 SHIFT 
> instructions.

But check out the ES .03 vs Tyconvert (above). ExtractStream
uses 12 on the first then shifts 4 again. Thats 16, right? Tyconvert
and Splitstream seem to have it correct, whereas ES doesn't. I outlined
the matching () above for clarity. I double checked my es .03c source code
from cvs on this as well?

Dale