Boost logo

Boost :

From: Oleg Abrosimov (olegabr_at_[hidden])
Date: 2006-12-02 07:04:45


Hello,

First, I want to thank Stephen Cleary for the Boost.Pool library.
Recently it saves our project by dramatically reducing memory usage in
std::list<> of many small objects.

However, there were about a hundred of warnings in the pool.hpp file
in lines that contain this code:

static_cast<bool>(total_req_size % partition_size);

There are three such a places in this file. I've refactored this code in
one function, removed the cast:

     size_type calc_num_chunks(const size_type n)
     {
       const size_type partition_size = alloc_size();
       const size_type total_req_size = n * requested_size;
       return total_req_size / partition_size +
           (total_req_size % partition_size) != 0 ? 1 : 0;
     }

and replaced all three occurrences of this code snippet by a call to
this simple function. All warnings have disappeared, my code still works
fine.

Please, make this little change in the upcoming boost release, if it is
not too late.

Best,
Oleg Abrosimov.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk