aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar bungeman <bungeman@google.com>2016-10-26 12:11:28 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-10-26 12:11:28 -0700
commit6f4293af6906721f09a12818ff3adc767badb3c7 (patch)
tree5f20f97f3ec6d9fee47584da76347392f4151591
parenta5fb6157e5908c1db9a1e55785dec20dde3eaf69 (diff)
Move when swapping, if possible.
This change was avoided in the past because vc++ 2013 (12.0) did not properly create default move constructors and move assignment operators. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2454763002 TBR=reed Verbal lgtm Review-Url: https://codereview.chromium.org/2454763002
-rw-r--r--include/core/SkTypes.h6
-rw-r--r--src/core/SkTSort.h6
2 files changed, 6 insertions, 6 deletions
diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h
index 0cef8a1257..0a3e3ac487 100644
--- a/include/core/SkTypes.h
+++ b/include/core/SkTypes.h
@@ -396,9 +396,9 @@ static inline constexpr int Sk32ToBool(uint32_t n) {
/** Generic swap function. Classes with efficient swaps should specialize this function to take
their fast path. This function is used by SkTSort. */
template <typename T> inline void SkTSwap(T& a, T& b) {
- T c(a);
- a = b;
- b = c;
+ T c(std::move(a));
+ a = std::move(b);
+ b = std::move(c);
}
static inline int32_t SkAbs32(int32_t value) {
diff --git a/src/core/SkTSort.h b/src/core/SkTSort.h
index 7101bab9ba..893af8703a 100644
--- a/src/core/SkTSort.h
+++ b/src/core/SkTSort.h
@@ -119,13 +119,13 @@ template <typename T> void SkTHeapSort(T array[], size_t count) {
/** Sorts the array of size count using comparator lessThan using an Insertion Sort algorithm. */
template <typename T, typename C> static void SkTInsertionSort(T* left, T* right, C lessThan) {
for (T* next = left + 1; next <= right; ++next) {
- T insert = *next;
+ T insert = std::move(*next);
T* hole = next;
while (left < hole && lessThan(insert, *(hole - 1))) {
- *hole = *(hole - 1);
+ *hole = std::move(*(hole - 1));
--hole;
}
- *hole = insert;
+ *hole = std::move(insert);
}
}