From ad512797c9405f78b080a1d24cd98f465b9879dd Mon Sep 17 00:00:00 2001 From: herb Date: Sun, 6 Nov 2016 21:07:02 -0800 Subject: 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 --- src/core/SkSmallAllocator.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/core/SkSmallAllocator.h') 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 +#include /* * Template class for allocating small objects without additional heap memory @@ -56,12 +57,12 @@ public: * will be returned. */ template - T* createT(const Args&... args) { + T* createT(Args&&... args) { void* buf = this->reserveT(); if (nullptr == buf) { return nullptr; } - return new (buf) T(args...); + return new (buf) T(std::forward(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 -- cgit v1.2.3