Skip to content
Snippets Groups Projects
Verified Commit 75b000a0 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Macro processor: ensure that all read-accessors return a const reference

Useless copies are thus avoided in some situations.
parent 8c1e48a0
Branches
Tags
No related merge requests found
Pipeline #1611 passed
......@@ -71,7 +71,7 @@ namespace macro
Include(ExpressionPtr expr_arg, Environment &env_arg, Tokenizer::location location_arg) :
Directive(env_arg, move(location_arg)), expr{move(expr_arg)} { }
void interpret(ostream &output, bool no_line_macro) override;
inline string getName() const { return name; }
inline const string & getName() const { return name; }
};
......@@ -84,7 +84,7 @@ namespace macro
IncludePath(ExpressionPtr expr_arg, Environment &env_arg, Tokenizer::location location_arg) :
Directive(env_arg, move(location_arg)), expr{move(expr_arg)} { }
void interpret(ostream &output, bool no_line_macro) override;
inline string getPath() const { return path; }
inline const string & getPath() const { return path; }
};
......
......
......@@ -378,8 +378,8 @@ namespace macro
public:
inline size_t size() const { return tup.size(); }
inline bool empty() const { return tup.empty(); }
inline vector<ExpressionPtr> getValue() const { return tup; }
inline ExpressionPtr at(int i) const { return tup.at(i); }
inline const vector<ExpressionPtr> & getValue() const { return tup; }
inline const ExpressionPtr & at(int i) const { return tup.at(i); }
BoolPtr is_equal(const BaseTypePtr &btp) const override;
inline BoolPtr istuple() const override { return make_shared<Bool>(true, env, location); }
BoolPtr contains(const BaseTypePtr &btp) const override;
......@@ -418,8 +418,8 @@ namespace macro
ExpressionPtr clone() const noexcept override;
public:
inline size_t size() const { return arr.size(); }
inline vector<ExpressionPtr> getValue() const { return arr; }
inline ExpressionPtr at(int i) const { return arr.at(i); }
inline const vector<ExpressionPtr> & getValue() const { return arr; }
inline const ExpressionPtr & at(int i) const { return arr.at(i); }
inline bool empty() const { return arr.empty() && !range1 && !range2; }
BaseTypePtr plus(const BaseTypePtr &bt) const override;
BaseTypePtr minus(const BaseTypePtr &bt) const override;
......@@ -466,7 +466,7 @@ namespace macro
make_shared<Variable>(name, env, location);
}
public:
inline string getName() const noexcept { return name; }
inline const string & getName() const noexcept { return name; }
inline codes::BaseType getType() const { return env.getType(name); }
};
......@@ -491,8 +491,8 @@ namespace macro
public:
inline void printName(ostream &output) const noexcept { output << name; }
void printArgs(ostream &output) const noexcept;
inline string getName() const { return name; }
inline vector<ExpressionPtr> getArgs() const { return args; }
inline const string & getName() const { return name; }
inline const vector<ExpressionPtr> & getArgs() const { return args; }
};
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment