Opened 7 years ago

#11244 new Feature Requests

A version of vector optimized for the empty case

Reported by: marc.glisse@… Owned by: Ion Gaztañaga
Milestone: To Be Determined Component: container
Version: Boost 1.58.0 Severity: Optimization
Keywords: Cc:

Description

Hello,

it would be useful if boost could provide a version of vector optimized for the case where the vector is empty. In particular, sizeof(vector)==sizeof(void*) with no allocation in the empty case. The size and capacity can be stored in the allocated region when that region exists. This technique can be seen in mozilla's nsTArray, libstdc++'s std::string (before the new ABI in gcc-5) and several other places. Like mozilla, I would like to use this in a tree-like structure, and a large proportion of the nodes are leaves with an empty vector, where 2 pointers make a noticable difference. To be precise, I would actually want a flat_set with a map-like interface (the key can be deduced from the value), but a vector would be a good start.

Change History (0)

Note: See TracTickets for help on using tickets.