From 04fadc84a654fe58ae27369c396ed66f9d97898a Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Sun, 28 Jul 2013 03:41:04 -0700 Subject: [PATCH] Rename to swapWith and use a template parameter --- modules/beast_core/containers/beast_Array.h | 4 ++-- modules/beast_core/containers/beast_HashMap.h | 7 ++++--- modules/beast_core/containers/beast_OwnedArray.h | 5 +++-- modules/beast_core/containers/beast_SharedObjectArray.h | 6 +++--- modules/beast_core/containers/beast_SortedSet.h | 5 +++-- modules/beast_core/text/beast_StringArray.cpp | 2 +- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/modules/beast_core/containers/beast_Array.h b/modules/beast_core/containers/beast_Array.h index 74f800068..6feb2fdc1 100644 --- a/modules/beast_core/containers/beast_Array.h +++ b/modules/beast_core/containers/beast_Array.h @@ -132,7 +132,7 @@ public: if (this != &other) { Array otherCopy (other); - swapWithArray (otherCopy); + swapWith (otherCopy); } return *this; @@ -577,7 +577,7 @@ public: because it just swaps their internal pointers. */ template - void swapWithArray (OtherArrayType& otherArray) noexcept + void swapWith (OtherArrayType& otherArray) noexcept { const ScopedLockType lock1 (getLock()); const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock()); diff --git a/modules/beast_core/containers/beast_HashMap.h b/modules/beast_core/containers/beast_HashMap.h index 7619e3dc5..ce467371d 100644 --- a/modules/beast_core/containers/beast_HashMap.h +++ b/modules/beast_core/containers/beast_HashMap.h @@ -354,12 +354,13 @@ public: //============================================================================== /** Efficiently swaps the contents of two hash-maps. */ - void swapWith (HashMap& otherHashMap) noexcept + template + void swapWith (OtherHashMapType& otherHashMap) noexcept { const ScopedLockType lock1 (getLock()); - const ScopedLockType lock2 (otherHashMap.getLock()); + const typename OtherHashMapType::ScopedLockType lock2 (otherHashMap.getLock()); - slots.swapWithArray (otherHashMap.slots); + slots.swapWith (otherHashMap.slots); std::swap (totalNumItems, otherHashMap.totalNumItems); } diff --git a/modules/beast_core/containers/beast_OwnedArray.h b/modules/beast_core/containers/beast_OwnedArray.h index 022188ec1..9049bf010 100644 --- a/modules/beast_core/containers/beast_OwnedArray.h +++ b/modules/beast_core/containers/beast_OwnedArray.h @@ -788,10 +788,11 @@ public: If you need to exchange two arrays, this is vastly quicker than using copy-by-value because it just swaps their internal pointers. */ - void swapWithArray (OwnedArray& otherArray) noexcept + template + void swapWith (OtherArrayType& otherArray) noexcept { const ScopedLockType lock1 (getLock()); - const ScopedLockType lock2 (otherArray.getLock()); + const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock()); data.swapWith (otherArray.data); std::swap (numUsed, otherArray.numUsed); diff --git a/modules/beast_core/containers/beast_SharedObjectArray.h b/modules/beast_core/containers/beast_SharedObjectArray.h index 0b775ed77..e79bf53a0 100644 --- a/modules/beast_core/containers/beast_SharedObjectArray.h +++ b/modules/beast_core/containers/beast_SharedObjectArray.h @@ -91,7 +91,7 @@ public: SharedObjectArray& operator= (const SharedObjectArray& other) noexcept { SharedObjectArray otherCopy (other); - swapWithArray (otherCopy); + swapWith (otherCopy); return *this; } @@ -102,7 +102,7 @@ public: SharedObjectArray& operator= (const SharedObjectArray& other) noexcept { SharedObjectArray otherCopy (other); - swapWithArray (otherCopy); + swapWith (otherCopy); return *this; } @@ -741,7 +741,7 @@ public: because it just swaps their internal pointers. */ template - void swapWithArray (OtherArrayType& otherArray) noexcept + void swapWith (OtherArrayType& otherArray) noexcept { const ScopedLockType lock1 (getLock()); const typename OtherArrayType::ScopedLockType lock2 (otherArray.getLock()); diff --git a/modules/beast_core/containers/beast_SortedSet.h b/modules/beast_core/containers/beast_SortedSet.h index 0af215fff..3227892ca 100644 --- a/modules/beast_core/containers/beast_SortedSet.h +++ b/modules/beast_core/containers/beast_SortedSet.h @@ -443,9 +443,10 @@ public: If you need to exchange two arrays, this is vastly quicker than using copy-by-value because it just swaps their internal pointers. */ - void swapWith (SortedSet& otherSet) noexcept + template + void swapWith (OtherSortedSetType& otherSet) noexcept { - data.swapWithArray (otherSet.data); + data.swapWith (otherSet.data); } //============================================================================== diff --git a/modules/beast_core/text/beast_StringArray.cpp b/modules/beast_core/text/beast_StringArray.cpp index 26a7a2ef7..98d34ffd9 100644 --- a/modules/beast_core/text/beast_StringArray.cpp +++ b/modules/beast_core/text/beast_StringArray.cpp @@ -122,7 +122,7 @@ bool StringArray::operator!= (const StringArray& other) const noexcept void StringArray::swapWith (StringArray& other) noexcept { - strings.swapWithArray (other.strings); + strings.swapWith (other.strings); } void StringArray::clear()