diff options
Diffstat (limited to 'include/core')
-rw-r--r-- | include/core/SkString.h | 6 | ||||
-rw-r--r-- | include/core/SkTypes.h | 2 |
2 files changed, 8 insertions, 0 deletions
diff --git a/include/core/SkString.h b/include/core/SkString.h index 4a6e2aa4e0..4366630ef2 100644 --- a/include/core/SkString.h +++ b/include/core/SkString.h @@ -244,4 +244,10 @@ private: /// Creates a new string and writes into it using a printf()-style format. SkString SkStringPrintf(const char* format, ...); +// Specialized to take advantage of SkString's fast swap path. The unspecialized function is +// declared in SkTypes.h and called by SkTSort. +template <> inline void SkTSwap(SkString& a, SkString& b) { + a.swap(b); +} + #endif diff --git a/include/core/SkTypes.h b/include/core/SkTypes.h index cbba50cc1b..ae27089bf7 100644 --- a/include/core/SkTypes.h +++ b/include/core/SkTypes.h @@ -276,6 +276,8 @@ static inline int Sk32ToBool(uint32_t n) { return (n | (0-n)) >> 31; } +/** 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; |