mirror of
https://github.com/NixOS/nix.git
synced 2025-11-15 23:12:44 +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
|
|
@ -2,19 +2,9 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
Pos::Pos(const Pos * other)
|
||||
Pos::operator std::shared_ptr<const Pos>() const
|
||||
{
|
||||
if (!other) {
|
||||
return;
|
||||
}
|
||||
line = other->line;
|
||||
column = other->column;
|
||||
origin = other->origin;
|
||||
}
|
||||
|
||||
Pos::operator std::shared_ptr<Pos>() const
|
||||
{
|
||||
return std::make_shared<Pos>(&*this);
|
||||
return std::make_shared<const Pos>(*this);
|
||||
}
|
||||
|
||||
std::optional<LinesOfCode> Pos::getCodeLines() const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue