Skip to content

Commit

Permalink
Functors refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
morzhovets committed Sep 8, 2023
1 parent 6a80778 commit e91b904
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions include/momo/HashSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -1284,12 +1284,12 @@ class HashSet
--bucketIter;
size_t hashCode = bucket.GetHashCodePart(hashCodeFullGetter, bucketIter, i,
buckets->GetLogCount(), mBuckets->GetLogCount());
auto itemReplacer = [this, hashCode, &memManager] (Item& backItem, Item& item)
auto itemReplacer = [this, hashCode, &memManager] (Item& srcItem, Item& dstItem)
{
(void)backItem;
MOMO_ASSERT(std::addressof(backItem) == std::addressof(item));
auto itemCreator = [&memManager, &item] (Item* newItem)
{ ItemTraits::Relocate(&memManager, item, newItem); };
(void)srcItem;
MOMO_ASSERT(std::addressof(srcItem) == std::addressof(dstItem));
auto itemCreator = [&memManager, &dstItem] (Item* newItem)
{ ItemTraits::Relocate(&memManager, dstItem, newItem); };
pvAddNogrow<false>(*mBuckets, hashCode, itemCreator);
};
bucketIter = bucket.Remove(bucketParams, bucketIter, itemReplacer);
Expand Down
12 changes: 6 additions & 6 deletions include/momo/TreeSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -1407,12 +1407,12 @@ class TreeSet
else
{
size_t childItemIndex = childNode->GetCount() - 1;
auto itemRemover2 = [node, itemIndex, &itemReplacer] (Item& item)
auto itemReplaceRemover = [node, itemIndex, &itemReplacer] (Item& item)
{ std::forward<ItemReplacer>(itemReplacer)(item, *node->GetItemPtr(itemIndex)); };
if (childNode->IsLeaf())
childNode->Remove(*mNodeParams, childItemIndex, itemRemover2);
childNode->Remove(*mNodeParams, childItemIndex, itemReplaceRemover);
else
pvDestroyInternal(childNode, childItemIndex, true, itemRemover2);
pvDestroyInternal(childNode, childItemIndex, true, itemReplaceRemover);
resNode = node->GetChild(itemIndex + 1);
}
while (!resNode->IsLeaf())
Expand Down Expand Up @@ -1446,18 +1446,18 @@ class TreeSet
if (node1 != comNode)
{
--itemIndex1;
auto itemReplacer = [this, comNode, comIndex1] (Item& item)
auto itemReplaceRemover = [this, comNode, comIndex1] (Item& item)
{ ItemTraits::Replace(GetMemManager(), item, *comNode->GetItemPtr(comIndex1)); };
if (node1->IsLeaf())
{
node1->Remove(*mNodeParams, itemIndex1, itemReplacer);
node1->Remove(*mNodeParams, itemIndex1, itemReplaceRemover);
for (size_t i = node1->GetCount(); i > itemIndex1; --i)
node1->Remove(*mNodeParams, i - 1, itemRemover);
pvToParent(node1, itemIndex1);
}
else
{
pvDestroyInternal(node1, itemIndex1, true, itemReplacer);
pvDestroyInternal(node1, itemIndex1, true, itemReplaceRemover);
}
while (node1 != comNode)
{
Expand Down

0 comments on commit e91b904

Please sign in to comment.