From 217d3bb7a8a6d98e8ce4286f08ad6a3a7c696154 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 --- Subtrees/beast/modules/beast_core/containers/beast_Array.h | 4 ++-- .../beast/modules/beast_core/containers/beast_HashMap.h | 7 ++++--- .../beast/modules/beast_core/containers/beast_OwnedArray.h | 5 +++-- .../beast_core/containers/beast_SharedObjectArray.h | 6 +++--- .../beast/modules/beast_core/containers/beast_SortedSet.h | 5 +++-- .../beast/modules/beast_core/text/beast_StringArray.cpp | 2 +- modules/ripple_core/validator/ripple_Validator.h | 2 +- modules/ripple_core/validator/ripple_Validators.cpp | 2 +- 8 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Subtrees/beast/modules/beast_core/containers/beast_Array.h b/Subtrees/beast/modules/beast_core/containers/beast_Array.h index 74f800068a..6feb2fdc13 100644 --- a/Subtrees/beast/modules/beast_core/containers/beast_Array.h +++ b/Subtrees/beast/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/Subtrees/beast/modules/beast_core/containers/beast_HashMap.h b/Subtrees/beast/modules/beast_core/containers/beast_HashMap.h index 7619e3dc59..ce467371d4 100644 --- a/Subtrees/beast/modules/beast_core/containers/beast_HashMap.h +++ b/Subtrees/beast/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/Subtrees/beast/modules/beast_core/containers/beast_OwnedArray.h b/Subtrees/beast/modules/beast_core/containers/beast_OwnedArray.h index 022188ec16..9049bf010b 100644 --- a/Subtrees/beast/modules/beast_core/containers/beast_OwnedArray.h +++ b/Subtrees/beast/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/Subtrees/beast/modules/beast_core/containers/beast_SharedObjectArray.h b/Subtrees/beast/modules/beast_core/containers/beast_SharedObjectArray.h index 0b775ed77b..e79bf53a03 100644 --- a/Subtrees/beast/modules/beast_core/containers/beast_SharedObjectArray.h +++ b/Subtrees/beast/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/Subtrees/beast/modules/beast_core/containers/beast_SortedSet.h b/Subtrees/beast/modules/beast_core/containers/beast_SortedSet.h index 0af215fffd..3227892cad 100644 --- a/Subtrees/beast/modules/beast_core/containers/beast_SortedSet.h +++ b/Subtrees/beast/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/Subtrees/beast/modules/beast_core/text/beast_StringArray.cpp b/Subtrees/beast/modules/beast_core/text/beast_StringArray.cpp index 26a7a2ef72..98d34ffd9d 100644 --- a/Subtrees/beast/modules/beast_core/text/beast_StringArray.cpp +++ b/Subtrees/beast/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() diff --git a/modules/ripple_core/validator/ripple_Validator.h b/modules/ripple_core/validator/ripple_Validator.h index 522ad1c6bc..d8f1a2133d 100644 --- a/modules/ripple_core/validator/ripple_Validator.h +++ b/modules/ripple_core/validator/ripple_Validator.h @@ -70,7 +70,7 @@ public: explicit List (SharedObjectArray & list) { - m_list.swapWithArray (list); + m_list.swapWith (list); } ~List () diff --git a/modules/ripple_core/validator/ripple_Validators.cpp b/modules/ripple_core/validator/ripple_Validators.cpp index 35545f4a21..acea75a224 100644 --- a/modules/ripple_core/validator/ripple_Validators.cpp +++ b/modules/ripple_core/validator/ripple_Validators.cpp @@ -167,7 +167,7 @@ public: sorted.addSorted (compare, arrayToSort [i]); } - arrayToSort.swapWithArray (sorted); + arrayToSort.swapWith (sorted); } // Given the old list and the new list for a source, this