Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
entities.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace bb::avm2 {
6
7// This helper lets us access entities by column.
8// It is critical to achieve performance when calculating lookup inverses.
9// See https://github.com/AztecProtocol/aztec-packages/pull/11605 for more details.
10template <typename Entities> auto& get_entity_by_column(Entities& entities, ColumnAndShifts c)
11{
12 // A statically constructed pointer to members of the class, indexed by column.
13 // This should only be created once per Entities class.
14 static std::array<typename Entities::DataType(Entities::*), NUM_COLUMNS_WITH_SHIFTS> col_ptrs = {
15 AVM2_ALL_ENTITIES_E(&Entities::)
16 };
17 return (entities.*col_ptrs[static_cast<size_t>(c)]);
18}
19
20} // namespace bb::avm2
#define AVM2_ALL_ENTITIES_E(e)
Definition columns.hpp:16
auto & get_entity_by_column(Entities &entities, ColumnAndShifts c)
Definition entities.hpp:10
constexpr auto NUM_COLUMNS_WITH_SHIFTS
Definition columns.hpp:40
ColumnAndShifts
Definition columns.hpp:35