LinkedLists: Rename MoveFrom method to TakeFrom.

"Move" now sounds like it has 'move' semantics (i.e. replaces this
structure's data with the other structure's data), while MoveFrom()
really had 'move+append' semantics (appends the other list's elements
to this list, and clears the other list.) To make this clearer, it's
here renamed to "TakeFrom".

This should reduce confusion with the other move-related APIs that
are starting to show up in the Haiku tree (e.g. "MoveFrom" in BRegion.)

Change-Id: Ib0a61a9c12fe8812020efd55a2a0818883883e2a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/8634
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
Reviewed-by: X512 X512 <[email protected]>
This commit is contained in:
Augustin Cavalier
2024-12-11 19:09:25 +00:00
committed by waddlesplash
parent 3fef105fae
commit 254894210c
31 changed files with 42 additions and 42 deletions
+3 -3
View File
@@ -335,7 +335,7 @@ public:
inline void Swap(Element *a, Element *b); inline void Swap(Element *a, Element *b);
inline void MoveFrom(DOUBLY_LINKED_LIST_CLASS_NAME *fromList); inline void TakeFrom(DOUBLY_LINKED_LIST_CLASS_NAME *fromList);
inline void RemoveAll(); inline void RemoveAll();
inline void MakeEmpty() { RemoveAll(); } inline void MakeEmpty() { RemoveAll(); }
@@ -516,10 +516,10 @@ DOUBLY_LINKED_LIST_CLASS_NAME::Swap(Element *a, Element *b)
} }
} }
// MoveFrom // TakeFrom
DOUBLY_LINKED_LIST_TEMPLATE_LIST DOUBLY_LINKED_LIST_TEMPLATE_LIST
void void
DOUBLY_LINKED_LIST_CLASS_NAME::MoveFrom(DOUBLY_LINKED_LIST_CLASS_NAME *fromList) DOUBLY_LINKED_LIST_CLASS_NAME::TakeFrom(DOUBLY_LINKED_LIST_CLASS_NAME *fromList)
{ {
if (fromList && fromList->fFirst) { if (fromList && fromList->fFirst) {
if (fFirst) { if (fFirst) {
@@ -340,7 +340,7 @@ public:
inline void Swap(Element* a, Element* b); inline void Swap(Element* a, Element* b);
inline void MoveFrom(DOUBLY_LINKED_LIST_CLASS_NAME* fromList); inline void TakeFrom(DOUBLY_LINKED_LIST_CLASS_NAME* fromList);
inline void RemoveAll(); inline void RemoveAll();
inline void MakeEmpty() { RemoveAll(); } inline void MakeEmpty() { RemoveAll(); }
@@ -552,10 +552,10 @@ DOUBLY_LINKED_LIST_CLASS_NAME::Swap(Element* a, Element* b)
} }
} }
// MoveFrom // TakeFrom
DOUBLY_LINKED_LIST_TEMPLATE_LIST DOUBLY_LINKED_LIST_TEMPLATE_LIST
void void
DOUBLY_LINKED_LIST_CLASS_NAME::MoveFrom(DOUBLY_LINKED_LIST_CLASS_NAME* fromList) DOUBLY_LINKED_LIST_CLASS_NAME::TakeFrom(DOUBLY_LINKED_LIST_CLASS_NAME* fromList)
{ {
if (fromList && fromList->fFirst) { if (fromList && fromList->fFirst) {
if (fFirst) { if (fFirst) {
@@ -145,7 +145,7 @@ public:
inline void Swap(Element *a, Element *b); inline void Swap(Element *a, Element *b);
inline void MoveFrom(DOUBLY_LINKED_QUEUE_CLASS_NAME *fromList); inline void TakeFrom(DOUBLY_LINKED_QUEUE_CLASS_NAME *fromList);
inline void RemoveAll(); inline void RemoveAll();
inline void MakeEmpty() { RemoveAll(); } inline void MakeEmpty() { RemoveAll(); }
@@ -281,10 +281,10 @@ DOUBLY_LINKED_QUEUE_CLASS_NAME::Swap(Element *a, Element *b)
} }
} }
// MoveFrom // TakeFrom
DOUBLY_LINKED_LIST_TEMPLATE_LIST DOUBLY_LINKED_LIST_TEMPLATE_LIST
void void
DOUBLY_LINKED_QUEUE_CLASS_NAME::MoveFrom(DOUBLY_LINKED_QUEUE_CLASS_NAME *fromList) DOUBLY_LINKED_QUEUE_CLASS_NAME::TakeFrom(DOUBLY_LINKED_QUEUE_CLASS_NAME *fromList)
{ {
if (fromList && fromList->fFirst) { if (fromList && fromList->fFirst) {
if (fFirst) { if (fFirst) {
@@ -148,7 +148,7 @@ class SinglyLinkedList {
inline bool Remove(Element* element); inline bool Remove(Element* element);
inline void Remove(Element* previous, Element* element); inline void Remove(Element* previous, Element* element);
inline void MoveFrom(SINGLY_LINKED_LIST_CLASS_NAME* fromList); inline void TakeFrom(SINGLY_LINKED_LIST_CLASS_NAME* fromList);
// O(1) if either list is empty, otherwise O(n). // O(1) if either list is empty, otherwise O(n).
inline void RemoveAll(); inline void RemoveAll();
@@ -240,7 +240,7 @@ SINGLY_LINKED_LIST_CLASS_NAME::Remove(Element* previous, Element* element)
SINGLY_LINKED_LIST_TEMPLATE_LIST SINGLY_LINKED_LIST_TEMPLATE_LIST
void void
SINGLY_LINKED_LIST_CLASS_NAME::MoveFrom(SINGLY_LINKED_LIST_CLASS_NAME* fromList) SINGLY_LINKED_LIST_CLASS_NAME::TakeFrom(SINGLY_LINKED_LIST_CLASS_NAME* fromList)
{ {
if (fromList->fFirst == NULL) if (fromList->fFirst == NULL)
return; return;
@@ -332,7 +332,7 @@ AttributeIndex::NodeChanged(Node* node, uint32 statFields,
const OldNodeAttributes& oldAttributes) const OldNodeAttributes& oldAttributes)
{ {
IteratorList iterators; IteratorList iterators;
iterators.MoveFrom(fIteratorsToUpdate); iterators.TakeFrom(fIteratorsToUpdate);
TreeValue* oldTreeValue TreeValue* oldTreeValue
= (TreeValue*)oldAttributes.IndexCookieForAttribute(Name()); = (TreeValue*)oldAttributes.IndexCookieForAttribute(Name());
@@ -200,7 +200,7 @@ LastModifiedIndex::NodeChanged(Node* node, uint32 statFields,
const OldNodeAttributes& oldAttributes) const OldNodeAttributes& oldAttributes)
{ {
IteratorList iterators; IteratorList iterators;
iterators.MoveFrom(fIteratorsToUpdate); iterators.TakeFrom(fIteratorsToUpdate);
time_t oldLastModified = oldAttributes.ModifiedTime().tv_sec; time_t oldLastModified = oldAttributes.ModifiedTime().tv_sec;
time_t newLastModified = node->ModifiedTime().tv_sec; time_t newLastModified = node->ModifiedTime().tv_sec;
@@ -199,7 +199,7 @@ SizeIndex::NodeChanged(Node* node, uint32 statFields,
const OldNodeAttributes& oldAttributes) const OldNodeAttributes& oldAttributes)
{ {
IteratorList iterators; IteratorList iterators;
iterators.MoveFrom(fIteratorsToUpdate); iterators.TakeFrom(fIteratorsToUpdate);
off_t oldSize = oldAttributes.FileSize(); off_t oldSize = oldAttributes.FileSize();
off_t newSize = node->FileSize(); off_t newSize = node->FileSize();
@@ -231,7 +231,7 @@ UnpackingLeafNode::CloneTransferPackageNodes(ino_t id, UnpackingNode*& _newNode)
fFinalPackageNode = fPackageNodes.Head(); fFinalPackageNode = fPackageNodes.Head();
if (fFinalPackageNode != NULL) { if (fFinalPackageNode != NULL) {
fFinalPackageNode->AcquireReference(); fFinalPackageNode->AcquireReference();
clone->fPackageNodes.MoveFrom(&fPackageNodes); clone->fPackageNodes.TakeFrom(&fPackageNodes);
} }
_newNode = clone; _newNode = clone;
@@ -436,7 +436,7 @@ CachedDataReader::_UnlockCacheLine(CacheLineLocker* lineLocker)
fCacheLineLockers.Remove(lineLocker); fCacheLineLockers.Remove(lineLocker);
if (CacheLineLocker* nextLineLocker = lineLocker->Queue().RemoveHead()) { if (CacheLineLocker* nextLineLocker = lineLocker->Queue().RemoveHead()) {
nextLineLocker->Queue().MoveFrom(&lineLocker->Queue()); nextLineLocker->Queue().TakeFrom(&lineLocker->Queue());
fCacheLineLockers.Insert(nextLineLocker); fCacheLineLockers.Insert(nextLineLocker);
nextLineLocker->WakeUp(); nextLineLocker->WakeUp();
} }
@@ -70,5 +70,5 @@ Resolvable::MoveDependencies(ResolvableDependencyList& dependencies)
dependency->SetResolvable(NULL); dependency->SetResolvable(NULL);
} }
dependencies.MoveFrom(&fDependencies); dependencies.TakeFrom(&fDependencies);
} }
@@ -205,7 +205,7 @@ Directory::RemoveEntry(Entry *entry)
if (nextEntry) { if (nextEntry) {
DoublyLinkedList<EntryIterator> *nextIterators DoublyLinkedList<EntryIterator> *nextIterators
= nextEntry->GetEntryIteratorList(); = nextEntry->GetEntryIteratorList();
nextIterators->MoveFrom(iterators); nextIterators->TakeFrom(iterators);
} else } else
iterators->RemoveAll(); iterators->RemoveAll();
GetVolume()->IteratorUnlock(); GetVolume()->IteratorUnlock();
@@ -215,7 +215,7 @@ Node::RemoveAttribute(Attribute *attribute)
if (nextAttr != NULL) { if (nextAttr != NULL) {
DoublyLinkedList<AttributeIterator> *nextIterators DoublyLinkedList<AttributeIterator> *nextIterators
= nextAttr->GetAttributeIteratorList(); = nextAttr->GetAttributeIteratorList();
nextIterators->MoveFrom(iterators); nextIterators->TakeFrom(iterators);
} else } else
iterators->RemoveAll(); iterators->RemoveAll();
@@ -159,7 +159,7 @@ move_ancillary_data(ancillary_data_container* from,
return NULL; return NULL;
ancillary_data *ancillaryData = from->data_list.Head(); ancillary_data *ancillaryData = from->data_list.Head();
to->data_list.MoveFrom(&from->data_list); to->data_list.TakeFrom(&from->data_list);
return ancillaryData != NULL ? ancillaryData->Data() : NULL; return ancillaryData != NULL ? ancillaryData->Data() : NULL;
} }
@@ -241,7 +241,7 @@ struct ModelLoader::ExtendedThreadSchedulingState
bool PrepareThreadIORequests(Model::IORequest**& _requests, bool PrepareThreadIORequests(Model::IORequest**& _requests,
size_t& _requestCount) size_t& _requestCount)
{ {
fIORequests.MoveFrom(&fPendingIORequests); fIORequests.TakeFrom(&fPendingIORequests);
size_t requestCount = fIORequests.Count(); size_t requestCount = fIORequests.Count();
if (requestCount == 0) { if (requestCount == 0) {
+1 -1
View File
@@ -502,7 +502,7 @@ BTimedEventQueue::DoForEach(for_each_hook hook, void* context,
if (resort) { if (resort) {
QueueEntryList entries; QueueEntryList entries;
entries.MoveFrom(&fData->fEvents); entries.TakeFrom(&fData->fEvents);
fData->fEventCount = 0; fData->fEventCount = 0;
while (queue_entry* entry = entries.RemoveHead()) while (queue_entry* entry = entries.RemoveHead())
+1 -1
View File
@@ -731,7 +731,7 @@ Volume::ProcessPendingNodeMonitorEvents()
NodeMonitorEventList events; NodeMonitorEventList events;
{ {
AutoLocker<BLocker> eventsLock(fPendingNodeMonitorEventsLock); AutoLocker<BLocker> eventsLock(fPendingNodeMonitorEventsLock);
events.MoveFrom(&fPendingNodeMonitorEvents); events.TakeFrom(&fPendingNodeMonitorEvents);
} }
// process them // process them
@@ -538,7 +538,7 @@ ARMVMTranslationMap32Bit::UnmapArea(VMArea* area, bool deletingAddressSpace,
RecursiveLocker locker(fLock); RecursiveLocker locker(fLock);
VMAreaMappings mappings; VMAreaMappings mappings;
mappings.MoveFrom(&area->mappings); mappings.TakeFrom(&area->mappings);
for (VMAreaMappings::Iterator it = mappings.GetIterator(); for (VMAreaMappings::Iterator it = mappings.GetIterator();
vm_page_mapping* mapping = it.Next();) { vm_page_mapping* mapping = it.Next();) {
@@ -763,7 +763,7 @@ VMSAv8TranslationMap::UnmapArea(VMArea* area, bool deletingAddressSpace,
ThreadCPUPinner pinner(thread_get_current_thread()); ThreadCPUPinner pinner(thread_get_current_thread());
VMAreaMappings mappings; VMAreaMappings mappings;
mappings.MoveFrom(&area->mappings); mappings.TakeFrom(&area->mappings);
for (VMAreaMappings::Iterator it = mappings.GetIterator(); for (VMAreaMappings::Iterator it = mappings.GetIterator();
vm_page_mapping* mapping = it.Next();) { vm_page_mapping* mapping = it.Next();) {
@@ -659,7 +659,7 @@ M68KVMTranslationMap040::UnmapArea(VMArea* area, bool deletingAddressSpace,
RecursiveLocker locker(fLock); RecursiveLocker locker(fLock);
VMAreaMappings mappings; VMAreaMappings mappings;
mappings.MoveFrom(&area->mappings); mappings.TakeFrom(&area->mappings);
for (VMAreaMappings::Iterator it = mappings.GetIterator(); for (VMAreaMappings::Iterator it = mappings.GetIterator();
vm_page_mapping* mapping = it.Next();) { vm_page_mapping* mapping = it.Next();) {
@@ -887,7 +887,7 @@ PPCVMTranslationMap460::UnmapArea(VMArea* area, bool deletingAddressSpace,
RecursiveLocker locker(fLock); RecursiveLocker locker(fLock);
VMAreaMappings mappings; VMAreaMappings mappings;
mappings.MoveFrom(&area->mappings); mappings.TakeFrom(&area->mappings);
for (VMAreaMappings::Iterator it = mappings.GetIterator(); for (VMAreaMappings::Iterator it = mappings.GetIterator();
vm_page_mapping* mapping = it.Next();) { vm_page_mapping* mapping = it.Next();) {
@@ -887,7 +887,7 @@ PPCVMTranslationMapClassic::UnmapArea(VMArea* area, bool deletingAddressSpace,
RecursiveLocker locker(fLock); RecursiveLocker locker(fLock);
VMAreaMappings mappings; VMAreaMappings mappings;
mappings.MoveFrom(&area->mappings); mappings.TakeFrom(&area->mappings);
for (VMAreaMappings::Iterator it = mappings.GetIterator(); for (VMAreaMappings::Iterator it = mappings.GetIterator();
vm_page_mapping* mapping = it.Next();) { vm_page_mapping* mapping = it.Next();) {
@@ -479,7 +479,7 @@ RISCV64VMTranslationMap::UnmapArea(VMArea* area, bool deletingAddressSpace,
ThreadCPUPinner pinner(thread_get_current_thread()); ThreadCPUPinner pinner(thread_get_current_thread());
VMAreaMappings mappings; VMAreaMappings mappings;
mappings.MoveFrom(&area->mappings); mappings.TakeFrom(&area->mappings);
for (VMAreaMappings::Iterator it = mappings.GetIterator(); for (VMAreaMappings::Iterator it = mappings.GetIterator();
vm_page_mapping* mapping = it.Next();) { vm_page_mapping* mapping = it.Next();) {
@@ -521,7 +521,7 @@ X86VMTranslationMap32Bit::UnmapArea(VMArea* area, bool deletingAddressSpace,
RecursiveLocker locker(fLock); RecursiveLocker locker(fLock);
VMAreaMappings mappings; VMAreaMappings mappings;
mappings.MoveFrom(&area->mappings); mappings.TakeFrom(&area->mappings);
for (VMAreaMappings::Iterator it = mappings.GetIterator(); for (VMAreaMappings::Iterator it = mappings.GetIterator();
vm_page_mapping* mapping = it.Next();) { vm_page_mapping* mapping = it.Next();) {
@@ -524,7 +524,7 @@ X86VMTranslationMap64Bit::UnmapArea(VMArea* area, bool deletingAddressSpace,
ThreadCPUPinner pinner(thread_get_current_thread()); ThreadCPUPinner pinner(thread_get_current_thread());
VMAreaMappings mappings; VMAreaMappings mappings;
mappings.MoveFrom(&area->mappings); mappings.TakeFrom(&area->mappings);
for (VMAreaMappings::Iterator it = mappings.GetIterator(); for (VMAreaMappings::Iterator it = mappings.GetIterator();
vm_page_mapping* mapping = it.Next();) { vm_page_mapping* mapping = it.Next();) {
@@ -766,7 +766,7 @@ X86VMTranslationMapPAE::UnmapArea(VMArea* area, bool deletingAddressSpace,
RecursiveLocker locker(fLock); RecursiveLocker locker(fLock);
VMAreaMappings mappings; VMAreaMappings mappings;
mappings.MoveFrom(&area->mappings); mappings.TakeFrom(&area->mappings);
for (VMAreaMappings::Iterator it = mappings.GetIterator(); for (VMAreaMappings::Iterator it = mappings.GetIterator();
vm_page_mapping* mapping = it.Next();) { vm_page_mapping* mapping = it.Next();) {
+1 -1
View File
@@ -923,7 +923,7 @@ private:
teamLocker.Unlock(); teamLocker.Unlock();
fPreAllocatedThreadStates.MoveFrom(&fThreadStates); fPreAllocatedThreadStates.TakeFrom(&fThreadStates);
if (!_PreAllocateThreadStates(missing)) if (!_PreAllocateThreadStates(missing))
return false; return false;
@@ -365,7 +365,7 @@ IOSchedulerSimple::_Finisher()
} else { } else {
// Remove the request from the request owner. // Remove the request from the request owner.
IORequestOwner* owner = request->Owner(); IORequestOwner* owner = request->Owner();
owner->requests.MoveFrom(&owner->completed_requests); owner->requests.TakeFrom(&owner->completed_requests);
owner->requests.Remove(request); owner->requests.Remove(request);
request->SetOwner(NULL); request->SetOwner(NULL);
@@ -809,6 +809,6 @@ IOSchedulerSimple::_GetRequestOwner(team_id team, thread_id thread,
existingOwners.Add(owner); existingOwners.Add(owner);
} }
fUnusedRequestOwners.MoveFrom(&existingOwners); fUnusedRequestOwners.TakeFrom(&existingOwners);
return owner; return owner;
} }
+2 -2
View File
@@ -2009,10 +2009,10 @@ deferred_deleter(void *arg, int iteration)
return; return;
DeferredFreeList entries; DeferredFreeList entries;
entries.MoveFrom(&sDeferredFreeList); entries.TakeFrom(&sDeferredFreeList);
DeferredDeletableList deletables; DeferredDeletableList deletables;
deletables.MoveFrom(&sDeferredDeletableList); deletables.TakeFrom(&sDeferredDeletableList);
locker.Unlock(); locker.Unlock();
+3 -3
View File
@@ -3170,9 +3170,9 @@ team_remove_team(Team* team, pid_t& _signalGroup)
insert_team_into_parent(sKernelTeam, child); insert_team_into_parent(sKernelTeam, child);
// move job control entries too // move job control entries too
sKernelTeam->stopped_children.entries.MoveFrom( sKernelTeam->stopped_children.entries.TakeFrom(
&team->stopped_children.entries); &team->stopped_children.entries);
sKernelTeam->continued_children.entries.MoveFrom( sKernelTeam->continued_children.entries.TakeFrom(
&team->continued_children.entries); &team->continued_children.entries);
// If the team was a session leader with controlling terminal, // If the team was a session leader with controlling terminal,
@@ -3741,7 +3741,7 @@ AssociatedDataOwner::PrepareForDeletion()
// move all data to a temporary list and unset the owner // move all data to a temporary list and unset the owner
DataList list; DataList list;
list.MoveFrom(&fList); list.TakeFrom(&fList);
for (DataList::Iterator it = list.GetIterator(); for (DataList::Iterator it = list.GetIterator();
AssociatedData* data = it.Next();) { AssociatedData* data = it.Next();) {
+1 -1
View File
@@ -204,7 +204,7 @@ VMPageQueue::AppendUnlocked(PageList& pages, uint32 count)
InterruptsSpinLocker locker(fLock); InterruptsSpinLocker locker(fLock);
fPages.MoveFrom(&pages); fPages.TakeFrom(&pages);
fCount += count; fCount += count;
} }
+1 -1
View File
@@ -3881,7 +3881,7 @@ allocate_page_run(page_num_t start, page_num_t length, uint32 flags,
// add pages to target queue // add pages to target queue
if (pageState < PAGE_STATE_FIRST_UNQUEUED) { if (pageState < PAGE_STATE_FIRST_UNQUEUED) {
freePages.MoveFrom(&clearPages); freePages.TakeFrom(&clearPages);
sPageQueues[pageState].AppendUnlocked(freePages, length); sPageQueues[pageState].AppendUnlocked(freePages, length);
} }