From a912f6dd9a6712601f4675253ffce9b92fd369e0 Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Sat, 27 Feb 2021 08:32:04 -0800 Subject: [PATCH] tidying some interfaces --- src/Expr.cc | 2 +- src/Expr.h | 2 +- src/script_opt/Expr.cc | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Expr.cc b/src/Expr.cc index 8b620df2f3..f9ebde9ea9 100644 --- a/src/Expr.cc +++ b/src/Expr.cc @@ -468,7 +468,7 @@ NameExpr::NameExpr(IDPtr arg_id, bool const_init) } // This isn't in-lined to avoid needing to pull in ID.h. -IDPtr NameExpr::IdPtr() +const IDPtr& NameExpr::IdPtr() const { return id; } diff --git a/src/Expr.h b/src/Expr.h index 05b1e541fe..92edcf5197 100644 --- a/src/Expr.h +++ b/src/Expr.h @@ -405,7 +405,7 @@ public: explicit NameExpr(IDPtr id, bool const_init = false); ID* Id() const { return id.get(); } - IDPtr IdPtr(); + const IDPtr& IdPtr() const; ValPtr Eval(Frame* f) const override; void Assign(Frame* f, ValPtr v) override; diff --git a/src/script_opt/Expr.cc b/src/script_opt/Expr.cc index f4fb1ec1c5..b852f125b3 100644 --- a/src/script_opt/Expr.cc +++ b/src/script_opt/Expr.cc @@ -989,7 +989,7 @@ ExprPtr ModExpr::Duplicate() // nullptr, and the caller should have ensured that the starting point is // a disjunction (since a bare "/pat/ in var" by itself isn't a "cascade" // and doesn't present a potential optimization opportunity. -static bool is_pattern_cascade(ExprPtr e, IDPtr& id, +static bool is_pattern_cascade(const ExprPtr& e, IDPtr& id, std::vector& patterns) { auto lhs = e->GetOp1(); @@ -1002,7 +1002,7 @@ static bool is_pattern_cascade(ExprPtr e, IDPtr& id, rhs->Tag() != EXPR_NAME ) return false; - auto rhs_id = rhs->AsNameExpr()->IdPtr(); + const auto& rhs_id = rhs->AsNameExpr()->IdPtr(); if ( id && rhs_id != id ) return false;