Subject: [Boost-bugs] [Boost C++ Libraries] #9574: flat_set(rand_iter, rand_iter) should use reserve()
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-01-14 22:38:23
#9574: flat_set(rand_iter,rand_iter) should use reserve()
------------------------------+------------------------
Reporter: marc.glisse@⦠| Owner: igaztanaga
Type: Bugs | Status: new
Milestone: To Be Determined | Component: container
Version: Boost 1.54.0 | Severity: Problem
Keywords: |
------------------------------+------------------------
Constructing a flat_set (or flat_map or etc) from random access iterators
could reduce the reallocation cost by calling reserve.
{{{
#include <vector>
#include <boost/container/flat_set.hpp>
typedef boost::container::flat_set<int> S;
int main(){
std::vector<int> v{5,4,3,2,1,0};
S s(v.begin(),v.end());
}
}}}
I observed the calls to operator new, and it was called with the
arguments: 24, 4, 8, 12, 16, 24. Those allocations take a very significant
amount of time in my application. I would like operator new to only be
called twice, with argument 24.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9574> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC