aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/private
diff options
context:
space:
mode:
Diffstat (limited to 'include/private')
-rw-r--r--include/private/SkMessageBus.h2
-rw-r--r--include/private/SkTArray.h21
-rw-r--r--include/private/SkTDArray.h15
3 files changed, 25 insertions, 13 deletions
diff --git a/include/private/SkMessageBus.h b/include/private/SkMessageBus.h
index 6ddf82c446..19e937555d 100644
--- a/include/private/SkMessageBus.h
+++ b/include/private/SkMessageBus.h
@@ -93,7 +93,7 @@ void SkMessageBus<Message>::Inbox::poll(SkTArray<Message>* messages) {
SkASSERT(messages);
messages->reset();
SkAutoMutexAcquire lock(fMessagesMutex);
- fMessages.swap(messages);
+ fMessages.swap(*messages);
}
// ----------------------- Implementation of SkMessageBus -----------------------
diff --git a/include/private/SkTArray.h b/include/private/SkTArray.h
index c9bee99c6d..75cd001b72 100644
--- a/include/private/SkTArray.h
+++ b/include/private/SkTArray.h
@@ -298,18 +298,19 @@ public:
/** Swaps the contents of this array with that array. Does a pointer swap if possible,
otherwise copies the T values. */
- void swap(SkTArray* that) {
- if (this == that) {
+ void swap(SkTArray& that) {
+ using std::swap;
+ if (this == &that) {
return;
}
- if (fOwnMemory && that->fOwnMemory) {
- SkTSwap(fItemArray, that->fItemArray);
- SkTSwap(fCount, that->fCount);
- SkTSwap(fAllocCount, that->fAllocCount);
+ if (fOwnMemory && that.fOwnMemory) {
+ swap(fItemArray, that.fItemArray);
+ swap(fCount, that.fCount);
+ swap(fAllocCount, that.fAllocCount);
} else {
// This could be more optimal...
- SkTArray copy(std::move(*that));
- *that = std::move(*this);
+ SkTArray copy(std::move(that));
+ that = std::move(*this);
*this = std::move(copy);
}
}
@@ -563,6 +564,10 @@ private:
bool fReserved : 1;
};
+template <typename T, bool M> static inline void swap(SkTArray<T, M>& a, SkTArray<T, M>& b) {
+ a.swap(b);
+}
+
template<typename T, bool MEM_MOVE> constexpr int SkTArray<T, MEM_MOVE>::kMinHeapAllocCount;
/**
diff --git a/include/private/SkTDArray.h b/include/private/SkTDArray.h
index dd3212d0dd..c6bd4ffd37 100644
--- a/include/private/SkTDArray.h
+++ b/include/private/SkTDArray.h
@@ -13,6 +13,8 @@
#include "SkTo.h"
#include "SkTypes.h"
+#include <utility>
+
template <typename T> class SkTDArray {
public:
SkTDArray() : fArray(nullptr), fReserve(0), fCount(0) {}
@@ -67,10 +69,11 @@ public:
return !(a == b);
}
- void swap(SkTDArray<T>& other) {
- SkTSwap(fArray, other.fArray);
- SkTSwap(fReserve, other.fReserve);
- SkTSwap(fCount, other.fCount);
+ void swap(SkTDArray<T>& that) {
+ using std::swap;
+ swap(fArray, that.fArray);
+ swap(fReserve, that.fReserve);
+ swap(fCount, that.fCount);
}
bool isEmpty() const { return fCount == 0; }
@@ -371,4 +374,8 @@ private:
}
};
+template <typename T> static inline void swap(SkTDArray<T>& a, SkTDArray<T>& b) {
+ a.swap(b);
+}
+
#endif