Skip to content

Commit

Permalink
Introduce named constant to remove magical constant
Browse files Browse the repository at this point in the history
  • Loading branch information
Adda0 committed Oct 3, 2023
1 parent a372b2a commit 97f199e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions include/mata/parser/inter-aut.hh
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,18 @@ public:
* and q1 and s2 being children nodes of the root.
*/
class FormulaGraph {
private:
/// Maximal number of @c FormulaNode children in any @c FormulaGraph node (for AND, OR nodes). Only one (NOT node)
/// or zero (@c FormulaNode node) children may be used. Used as an optimalization by preallocating @c children at
/// node initialization.
static constexpr size_t MAX_NUM_OF_CHILDREN{ 2 };
public:
FormulaNode node{};
std::vector<FormulaGraph> children{};

FormulaGraph() = default;
explicit FormulaGraph(const FormulaNode& n) : node(n), children() { children.reserve(2); }
explicit FormulaGraph(FormulaNode&& n) : node(std::move(n)), children() { children.reserve(2); }
explicit FormulaGraph(const FormulaNode& n) : node(n), children() { children.reserve(MAX_NUM_OF_CHILDREN); }

Check warning on line 137 in include/mata/parser/inter-aut.hh

View check run for this annotation

Codecov / codecov/patch

include/mata/parser/inter-aut.hh#L137

Added line #L137 was not covered by tests
explicit FormulaGraph(FormulaNode&& n) : node(std::move(n)), children() { children.reserve(MAX_NUM_OF_CHILDREN); }
FormulaGraph(const FormulaGraph& g) : node(g.node), children(g.children) {}
FormulaGraph(FormulaGraph&& g) noexcept : node(std::move(g.node)), children(std::move(g.children)) {}

Expand Down

0 comments on commit 97f199e

Please sign in to comment.