Boost logo

Boost Users :

Subject: [Boost-users] [GIL] About `packed_channel_value` (possible improvement)
From: TONGARI (tongari95_at_[hidden])
Date: 2013-02-13 11:48:27


Hi,

I took a look into "channel.hpp" and found that packed_channel_value is not
very efficient in construction.
There are:

    packed_channel_value(integer_t v) { _value = static_cast< integer_t >(
v % num_values ); }

    // I have no idea why this exists, seems OK to remove it
    template <typename Scalar> packed_channel_value(Scalar v) { _value =
static_cast< integer_t >( v ) % num_values; }

IIUC, "v % num_values" above could be replaced with a much cheaper "v
& low_bits_mask_t<NumBits>::sig_bits_fast".
That is:

    packed_channel_value(integer_t v) : _value(v
& low_bits_mask_t<NumBits>::sig_bits_fast) {}

What do you think? Am I missing some point?

Thanks.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net