From 402ee8ab64f9b11989cbdcf53f8ca513cb25e23f Mon Sep 17 00:00:00 2001 From: Guillaume Maudoux Date: Thu, 28 Apr 2022 13:02:39 +0200 Subject: [PATCH] No point in passing string_views by reference --- src/libexpr/eval-inline.hh | 6 +++--- src/libexpr/eval.hh | 34 +++++++++++++++++----------------- src/libexpr/primops.cc | 2 +- src/libexpr/value.hh | 2 +- src/libutil/error.cc | 4 ++-- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/libexpr/eval-inline.hh b/src/libexpr/eval-inline.hh index 77ed07b2e..025459c00 100644 --- a/src/libexpr/eval-inline.hh +++ b/src/libexpr/eval-inline.hh @@ -128,7 +128,7 @@ void EvalState::forceValue(Value & v, Callable getPos) [[gnu::always_inline]] -inline void EvalState::forceAttrs(Value & v, const Pos & pos, const std::string_view & errorCtx) +inline void EvalState::forceAttrs(Value & v, const Pos & pos, std::string_view errorCtx) { forceAttrs(v, [&]() { return pos; }, errorCtx); } @@ -136,7 +136,7 @@ inline void EvalState::forceAttrs(Value & v, const Pos & pos, const std::string_ template [[gnu::always_inline]] -inline void EvalState::forceAttrs(Value & v, Callable getPos, const std::string_view & errorCtx) +inline void EvalState::forceAttrs(Value & v, Callable getPos, std::string_view errorCtx) { try { forceValue(v, noPos); @@ -152,7 +152,7 @@ inline void EvalState::forceAttrs(Value & v, Callable getPos, const std::string_ [[gnu::always_inline]] -inline void EvalState::forceList(Value & v, const Pos & pos, const std::string_view & errorCtx) +inline void EvalState::forceList(Value & v, const Pos & pos, std::string_view errorCtx) { try { forceValue(v, noPos); diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 18dbfc5a4..fd0961bdc 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -222,8 +222,8 @@ public: /* Evaluation the expression, then verify that it has the expected type. */ - inline bool evalBool(Env & env, Expr * e, const Pos & pos, const std::string_view & errorCtx); - inline void evalAttrs(Env & env, Expr * e, Value & v, const Pos & pos, const std::string_view & errorCtx); + inline bool evalBool(Env & env, Expr * e, const Pos & pos, std::string_view errorCtx); + inline void evalAttrs(Env & env, Expr * e, Value & v, const Pos & pos, std::string_view errorCtx); /* If `v' is a thunk, enter it and overwrite `v' with the result of the evaluation of the thunk. If `v' is a delayed function @@ -239,20 +239,20 @@ public: void forceValueDeep(Value & v); /* Force `v', and then verify that it has the expected type. */ - NixInt forceInt(Value & v, const Pos & pos, const std::string_view & errorCtx); - NixFloat forceFloat(Value & v, const Pos & pos, const std::string_view & errorCtx); - bool forceBool(Value & v, const Pos & pos, const std::string_view & errorCtx); + NixInt forceInt(Value & v, const Pos & pos, std::string_view errorCtx); + NixFloat forceFloat(Value & v, const Pos & pos, std::string_view errorCtx); + bool forceBool(Value & v, const Pos & pos, std::string_view errorCtx); - void forceAttrs(Value & v, const Pos & pos, const std::string_view & errorCtx); + void forceAttrs(Value & v, const Pos & pos, std::string_view errorCtx); template - inline void forceAttrs(Value & v, Callable getPos, const std::string_view & errorCtx); + inline void forceAttrs(Value & v, Callable getPos, std::string_view errorCtx); - inline void forceList(Value & v, const Pos & pos, const std::string_view & errorCtx); - void forceFunction(Value & v, const Pos & pos, const std::string_view & errorCtx); // either lambda or primop - std::string_view forceString(Value & v, const Pos & pos, const std::string_view & errorCtx); - std::string_view forceString(Value & v, PathSet & context, const Pos & pos, const std::string_view & errorCtx); - std::string_view forceStringNoCtx(Value & v, const Pos & pos, const std::string_view & errorCtx); + inline void forceList(Value & v, const Pos & pos, std::string_view errorCtx); + void forceFunction(Value & v, const Pos & pos, std::string_view errorCtx); // either lambda or primop + std::string_view forceString(Value & v, const Pos & pos, std::string_view errorCtx); + std::string_view forceString(Value & v, PathSet & context, const Pos & pos, std::string_view errorCtx); + std::string_view forceStringNoCtx(Value & v, const Pos & pos, std::string_view errorCtx); /* Return true iff the value `v' denotes a derivation (i.e. a set with attribute `type = "derivation"'). */ @@ -268,17 +268,17 @@ public: BackedStringView coerceToString(const Pos & pos, Value & v, PathSet & context, bool coerceMore = false, bool copyToStore = true, bool canonicalizePath = true, - const std::string_view & errorCtx = ""); + std::string_view errorCtx = ""); std::string copyPathToStore(PathSet & context, const Path & path); /* Path coercion. Converts strings, paths and derivations to a path. The result is guaranteed to be a canonicalised, absolute path. Nothing is copied to the store. */ - Path coerceToPath(const Pos & pos, Value & v, PathSet & context, const std::string_view & errorCtx); + Path coerceToPath(const Pos & pos, Value & v, PathSet & context, std::string_view errorCtx); /* Like coerceToPath, but the result must be a store path. */ - StorePath coerceToStorePath(const Pos & pos, Value & v, PathSet & context, const std::string_view & errorCtx); + StorePath coerceToStorePath(const Pos & pos, Value & v, PathSet & context, std::string_view errorCtx); public: @@ -334,7 +334,7 @@ public: /* Do a deep equality test between two values. That is, list elements and attributes are compared recursively. */ - bool eqValues(Value & v1, Value & v2, const Pos & pos, const std::string_view & errorCtx); + bool eqValues(Value & v1, Value & v2, const Pos & pos, std::string_view errorCtx); bool isFunctor(Value & fun); @@ -369,7 +369,7 @@ public: void mkThunk_(Value & v, Expr * expr); void mkPos(Value & v, ptr pos); - void concatLists(Value & v, size_t nrLists, Value * * lists, const Pos & pos, const std::string_view & errorCtx); + void concatLists(Value & v, size_t nrLists, Value * * lists, const Pos & pos, std::string_view errorCtx); /* Print statistics. */ void printStats(); diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index f99ab8ca8..9360c2102 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -552,7 +552,7 @@ struct CompareValues return (*this)(v1, v2, errorCtx); } - bool operator () (Value * v1, Value * v2, const std::string_view & errorCtx) const + bool operator () (Value * v1, Value * v2, std::string_view errorCtx) const { try { if (v1->type() == nFloat && v2->type() == nInt) diff --git a/src/libexpr/value.hh b/src/libexpr/value.hh index 403e38258..18e4218c5 100644 --- a/src/libexpr/value.hh +++ b/src/libexpr/value.hh @@ -85,7 +85,7 @@ class ExternalValueBase /* Coerce the value to a string. Defaults to uncoercable, i.e. throws an * error. */ - virtual std::string coerceToString(const Pos & pos, PathSet & context, bool copyMore, bool copyToStore, const std::string_view & errorCtx) const; + virtual std::string coerceToString(const Pos & pos, PathSet & context, bool copyMore, bool copyToStore, std::string_view errorCtx) const; /* Compare to another value of the same type. Defaults to uncomparable, * i.e. always false. diff --git a/src/libutil/error.cc b/src/libutil/error.cc index 7dc8c1941..3644cada9 100644 --- a/src/libutil/error.cc +++ b/src/libutil/error.cc @@ -347,7 +347,7 @@ std::ostream & showErrorInfo(std::ostream & out, const ErrorInfo & einfo, bool s * to make a decision between the two following options. * * ``` long traces - * inline void EvalState::evalAttrs(Env & env, Expr * e, Value & v, const Pos & pos, const std::string_view & errorCtx) + * inline void EvalState::evalAttrs(Env & env, Expr * e, Value & v, const Pos & pos, std::string_view errorCtx) * { * try { * e->eval(*this, env, v); @@ -361,7 +361,7 @@ std::ostream & showErrorInfo(std::ostream & out, const ErrorInfo & einfo, bool s * ``` * * ``` short traces - * inline void EvalState::evalAttrs(Env & env, Expr * e, Value & v, const Pos & pos, const std::string_view & errorCtx) + * inline void EvalState::evalAttrs(Env & env, Expr * e, Value & v, const Pos & pos, std::string_view errorCtx) * { * e->eval(*this, env, v); * try {