From: Frank Condello <[EMAIL PROTECTED]>
Date: Fri, 16 Feb 2007 15:42:39 -0500
On 16-Feb-07, at 3:16 PM, Peter K. Stys wrote:
On 2/16/07, Charles Yeomans <[EMAIL PROTECTED]> wrote:
The best thing would be to be able to pick a representation, say,
little endian, and use it always. If you have control over reading
and writing of image data, then you should be to do so.
Charles:
this would be easiest, but I suspect not best: if i used say
littleEndian always, then my app running on a bigEndian Mac would
always be forced to either byte-swap a 100 MB file during read/write,
or worse, force the memblocks to byte-swap every m.ushort access
because m would be set to its unnatural littleEndian setting on a
bigEndian machine. Or am I missing something?
The overhead of calling ushort is in the function call itself - if
you swap the whole block as Theo suggested you're actually doing
_more_ work. i.e. Calling bytevalue 4 times is way slower than
setting littleendian and calling ushort once. The littleendian
property is just a flag that's checked in every (applicable) accessor
whether the swap happens or not - there's nothing inherently slow
about it.
Simple maths proves you to be wrong.
If he is processing the entire file, my approach should be faster.
The only thing making my approach slow would be RB itself, seeing as
mb.bytevalue() may not be as fast as a pointer.
I think a plugin function could byte-swap the entire memoryblock,
though, and in this case it would be the fastest.
The thing is, my design is good, whether or not RB is making it
slower. Calling MB.MyCustomPluginByteSwapFunction is just the same
approach as what my code did, but faster.
Unless of course, Peter is not processing the entire memoryblock. If
he is only processing small parts, then actually he is better off
just setting .LittleEndian to true.
But I don't remember him stating if he processes only a small part,
or the entire thing multiple times.
If he is processing the entire file mulitple times, then even my code
using RB and no plugins is faster than your approach.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>