On 2/17/07, Joe Huber <[EMAIL PROTECTED]> wrote:
At 3:12 PM -0800 2/16/07, Mel Patrick wrote:
>I really liked the idea of the word/long read functions based the processor
>and I think I will implement those in future.

But the issue is NOT what processor is running, the issue is the
endianness of the DATA that needs to be read or written.

Hard coding the endianness to the processor means that files and
network streams would not be interoperable across machines that use a
different processor.

Personnally I think RB's approach of having the LittleEndian flag on
memory blocks and binary streams is exactly the right approach. It
handles everything in the simplest manner possible.


I agree it's the simplest, but unless I don't understand the
fundamentals I worry about the following (I'll use IntelEndian and
PPCEndian for clarity 'cause I never remember which is which):

If my PPC app saves a memblock to a file in PPCEndian order, then that
file is read in on an Intel Mac, into an IntelEndian memblock, said
IntelEndian memblock's flag will have to be reset to the non-native
PPCendian state so that multibyte data like shorts and longs will make
sense.  Do I have it right so far?

Now my app has to fly through these 100 MB memblocks to do math on
their ushorts.  If an Intel CPU reads in a ushort from a memblock
whose flag is set to PPCendian, the bytes will have to be swapped,
else Intel CPU will misinterpret the values.  These swaps will be
repeated 50 million times for each block, every time I access this
memblock.  I can't see it any other way.  And this would entail a
performance hit, possibly a big one given the numerous times it has to
be done.

So swapping bytes at read time once, and only if you have to, should
be much more efficient.

Do I misunderstand how this works?

P.

--
-------------------------------------------------------------------------------
Peter K. Stys, MD
Professor of Medicine(Neurology), Senior Scientist
Ottawa Health Research Institute, Div. of Neuroscience
Ottawa Hospital / University of Ottawa
Ontario, CANADA
tel:    (613)761-5444
fax:    (613)761-5330
http://www.ohri.ca/profiles/stys.asp
-------------------------------------------------------------------------------
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to