mirror of
https://github.com/NixOS/nix
synced 2025-06-30 11:43:15 +02:00
Extend internal API docs, part 2
Picking up from #8111. Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
This commit is contained in:
parent
8ae9d66940
commit
abd5e7dec0
32 changed files with 640 additions and 359 deletions
|
@ -7,20 +7,24 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
/* Provides an indexable container like vector<> with memory overhead
|
||||
guarantees like list<> by allocating storage in chunks of ChunkSize
|
||||
elements instead of using a contiguous memory allocation like vector<>
|
||||
does. Not using a single vector that is resized reduces memory overhead
|
||||
on large data sets by on average (growth factor)/2, mostly
|
||||
eliminates copies within the vector during resizing, and provides stable
|
||||
references to its elements. */
|
||||
/**
|
||||
* Provides an indexable container like vector<> with memory overhead
|
||||
* guarantees like list<> by allocating storage in chunks of ChunkSize
|
||||
* elements instead of using a contiguous memory allocation like vector<>
|
||||
* does. Not using a single vector that is resized reduces memory overhead
|
||||
* on large data sets by on average (growth factor)/2, mostly
|
||||
* eliminates copies within the vector during resizing, and provides stable
|
||||
* references to its elements.
|
||||
*/
|
||||
template<typename T, size_t ChunkSize>
|
||||
class ChunkedVector {
|
||||
private:
|
||||
uint32_t size_ = 0;
|
||||
std::vector<std::vector<T>> chunks;
|
||||
|
||||
/* keep this out of the ::add hot path */
|
||||
/**
|
||||
* Keep this out of the ::add hot path
|
||||
*/
|
||||
[[gnu::noinline]]
|
||||
auto & addChunk()
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue