Boost logo

Boost :

Subject: Re: [boost] [boost::endian] Summary of discussion #1
From: Scott McMurray ([hidden])
Date: 2010-06-02 12:55:57

On 2 June 2010 11:37, Tomas Puverle <tomas.puverle_at_[hidden]> wrote:
> Having said that, as the typed interface ultimately relies on copying of data,

I think the summary here is that the typed approach requires copying
while using members, and that the untyped approach may require
swapping before and after use.

Thinking about that, I believe I've come up with a situation in which
the typed approach is more efficient than the swapping one. Suppose
you want to know the width and height of a BMP image on a big-endian
machine. If you have a way to get around aliasing issues, then
memory-mapping the beginning of the file, type punning to the typed
header type, and reading out the 2 values you care about is faster
than swapping everything in the header. (Yes, you could just swap the
two fields you care about, for equivalent performance, but that's an
operation at a different granularity.)

Hoping that makes sense,
~ Scott McMurray

Boost list run by bdawes at, gregod at, cpdaniel at, john at