Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Unified Diff: src/core/SkSmallAllocator.h

Issue 2482683002: Use perfect forwarding in createT of SkSmallAllocator. (Closed)
Patch Set: Edits Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/utils/SkTextureCompressor_ASTC.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkSmallAllocator.h
diff --git a/src/core/SkSmallAllocator.h b/src/core/SkSmallAllocator.h
index 67afe756912bdd014945f0ba235dc9797cdc3aa7..13b1505821ab588f99a8a28fe21fc0ddd9a16cb9 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
« no previous file with comments | « no previous file | src/utils/SkTextureCompressor_ASTC.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698