mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:18:11 +00:00
LibSQL: Replace DownPointer copy constructor with move constructor
Avoids awkwardly const-casting the "other" DownPointer.
This commit is contained in:
parent
4283109c13
commit
948bd50197
2 changed files with 4 additions and 13 deletions
|
@ -34,20 +34,11 @@ DownPointer::DownPointer(TreeNode* owner, DownPointer& down)
|
|||
{
|
||||
}
|
||||
|
||||
DownPointer::DownPointer(DownPointer const& other)
|
||||
DownPointer::DownPointer(DownPointer&& other)
|
||||
: m_owner(other.m_owner)
|
||||
, m_pointer(other.pointer())
|
||||
, m_node(other.m_node ? move(other.m_node) : nullptr)
|
||||
{
|
||||
if (other.m_node)
|
||||
// FIXME This is gross. We modify the other object which we promised
|
||||
// to be const. However, this particular constructor is needed
|
||||
// when we take DownPointers from the Vector they live in when
|
||||
// we split a node. The original object is going to go away, so
|
||||
// there is no harm done. However, it's yucky. If anybody has
|
||||
// a better idea...
|
||||
m_node = move(const_cast<DownPointer&>(other).m_node);
|
||||
else
|
||||
m_node = nullptr;
|
||||
}
|
||||
|
||||
TreeNode* DownPointer::node()
|
||||
|
@ -336,7 +327,7 @@ void TreeNode::split()
|
|||
down.m_node->m_up = new_node;
|
||||
}
|
||||
new_node->m_entries.append(entry);
|
||||
new_node->m_down.append(down);
|
||||
new_node->m_down.append(move(down));
|
||||
}
|
||||
|
||||
// Move the median key in the node one level up. Its right node will
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue