1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-05 08:11:47 +02:00

libexpr: Remove unused field from SymbolTable::symbols and emplace into the ChunkedVector

Remove outdated and no longer relevant TODO. It's more confusing
now, since symbol table must now be addressed by uint32_t indices
in order to keep Attr size down to 16 bytes on 64 bit machines.
This commit is contained in:
Sergei Zimmerman 2025-05-02 20:42:47 +00:00
parent a976a46ee8
commit 161c5dbf39
No known key found for this signature in database
GPG key ID: A9B0B557CA632325
2 changed files with 20 additions and 11 deletions

View file

@ -45,9 +45,10 @@ public:
addChunk();
}
uint32_t size() const { return size_; }
uint32_t size() const noexcept { return size_; }
std::pair<T &, uint32_t> add(T value)
template <typename... Args>
std::pair<T &, uint32_t> add(Args &&... args)
{
const auto idx = size_++;
auto & chunk = [&] () -> auto & {
@ -55,11 +56,16 @@ public:
return back;
return addChunk();
}();
auto & result = chunk.emplace_back(std::move(value));
auto & result = chunk.emplace_back(std::forward<Args>(args)...);
return {result, idx};
}
const T & operator[](uint32_t idx) const
/**
* Unchecked subscript operator.
* @pre add must have been called at least idx + 1 times.
* @throws nothing
*/
const T & operator[](uint32_t idx) const noexcept
{
return chunks[idx / ChunkSize][idx % ChunkSize];
}