aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkSmallAllocator.h
diff options
context:
space:
mode:
authorGravatar herb <herb@google.com>2016-11-06 21:07:02 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-11-06 21:07:02 -0800
commitad512797c9405f78b080a1d24cd98f465b9879dd (patch)
treecd8fd44d95e9762713057555eb484759dac74029 /src/core/SkSmallAllocator.h
parentf98b730af08df5b7e6989d2fc1099fbbb07f26d9 (diff)
Use perfect forwarding in createT of SkSmallAllocator.
This allows createT statements to be written in a clearer style. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2482683002 Review-Url: https://codereview.chromium.org/2482683002
Diffstat (limited to 'src/core/SkSmallAllocator.h')
-rw-r--r--src/core/SkSmallAllocator.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/core/SkSmallAllocator.h b/src/core/SkSmallAllocator.h
index 67afe75691..13b1505821 100644
--- a/src/core/SkSmallAllocator.h
+++ b/src/core/SkSmallAllocator.h
@@ -12,6 +12,7 @@
#include "SkTypes.h"
#include <new>
+#include <utility>
/*
* Template class for allocating small objects without additional heap memory
@@ -56,12 +57,12 @@ public:
* will be returned.
*/
template<typename T, typename... Args>
- T* createT(const Args&... args) {
+ T* createT(Args&&... args) {
void* buf = this->reserveT<T>();
if (nullptr == buf) {
return nullptr;
}
- return new (buf) T(args...);
+ return new (buf) T(std::forward<Args>(args)...);
}
/*
@@ -130,10 +131,9 @@ private:
}
alignas(16) char fStorage[kTotalBytes];
- // Number of bytes used so far.
- size_t fStorageUsed;
- uint32_t fNumObjects;
- Rec fRecs[kMaxObjects];
+ size_t fStorageUsed; // Number of bytes used so far.
+ uint32_t fNumObjects;
+ Rec fRecs[kMaxObjects];
};
#endif // SkSmallAllocator_DEFINED