mirror of
https://github.com/NixOS/nix.git
synced 2025-11-16 07:22:43 +01:00
libutil: Use std::shared_ptr<const Pos> instead of std::shared_ptr<Pos>
There's actually no mutation happening so there's no point in using a mutable shared_ptr. Furthermore, this makes it much more evident to the reader that no actual mutation (especially in multithreaded case) is happening. Also get rid of redundant constructor that isn't actually used anywhere other than `Pos::operator std::shared_ptr<Pos>` which just passes in &*this, (identical to just `this`), which can't be nullptr.
This commit is contained in:
parent
587b5f5361
commit
b73e706589
5 changed files with 11 additions and 23 deletions
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
void BaseError::addTrace(std::shared_ptr<Pos> && e, HintFmt hint, TracePrint print)
|
||||
void BaseError::addTrace(std::shared_ptr<const Pos> && e, HintFmt hint, TracePrint print)
|
||||
{
|
||||
err.traces.push_front(Trace { .pos = std::move(e), .hint = hint, .print = print });
|
||||
}
|
||||
|
|
@ -146,7 +146,7 @@ static bool printUnknownLocations = getEnv("_NIX_EVAL_SHOW_UNKNOWN_LOCATIONS").h
|
|||
*
|
||||
* @return true if a position was printed.
|
||||
*/
|
||||
static bool printPosMaybe(std::ostream & oss, std::string_view indent, const std::shared_ptr<Pos> & pos) {
|
||||
static bool printPosMaybe(std::ostream & oss, std::string_view indent, const std::shared_ptr<const Pos> & pos) {
|
||||
bool hasPos = pos && *pos;
|
||||
if (hasPos) {
|
||||
oss << indent << ANSI_BLUE << "at " ANSI_WARNING << *pos << ANSI_NORMAL << ":";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue