diff options
author | Guillaume Maudoux <guillaume.maudoux@tweag.io> | 2022-04-28 13:02:39 +0200 |
---|---|---|
committer | Guillaume Maudoux <guillaume.maudoux@tweag.io> | 2022-04-28 13:02:39 +0200 |
commit | 402ee8ab64f9b11989cbdcf53f8ca513cb25e23f (patch) | |
tree | 1635e7fa11f516ee05ec6d6f90b937f837fa9778 /src/libexpr | |
parent | 5ef88457b8bdef957fcbb3cd0e7740595fad1949 (diff) |
No point in passing string_views by reference
Diffstat (limited to 'src/libexpr')
-rw-r--r-- | src/libexpr/eval-inline.hh | 6 | ||||
-rw-r--r-- | src/libexpr/eval.hh | 34 | ||||
-rw-r--r-- | src/libexpr/primops.cc | 2 | ||||
-rw-r--r-- | src/libexpr/value.hh | 2 |
4 files changed, 22 insertions, 22 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 <typename Callable> [[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 <typename Callable> - 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> 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. |