diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2023-04-01 12:42:03 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-01 12:42:03 -0400 |
commit | ea1cbc3df57d6625fa67248cc085f3fd91cba440 (patch) | |
tree | 0fa291d5a9197244adedfa49cd954fa537c78a99 /src/libutil/chunked-vector.hh | |
parent | 8ae9d669409851acb6de39335b11a95a991eae6d (diff) | |
parent | f4ab297b3185ca4214cfa83bbd4b8f0039b6fadf (diff) |
Merge pull request #8133 from obsidiansystems/improve-internal-api-docs
Extend internal API docs, part 2
Diffstat (limited to 'src/libutil/chunked-vector.hh')
-rw-r--r-- | src/libutil/chunked-vector.hh | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/libutil/chunked-vector.hh b/src/libutil/chunked-vector.hh index 0a4f0b400..d914e2542 100644 --- a/src/libutil/chunked-vector.hh +++ b/src/libutil/chunked-vector.hh @@ -1,4 +1,5 @@ #pragma once +///@file #include <cstdint> #include <cstdlib> @@ -7,20 +8,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() { |