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

Unified Diff: src/core/SkSmallAllocator.h

Issue 2482683002: Use perfect forwarding in createT of SkSmallAllocator. (Closed)
Patch Set: 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..5cae28519793c0c9cb21e20418e8c352f01b72a9 100644
--- a/src/core/SkSmallAllocator.h
+++ b/src/core/SkSmallAllocator.h
@@ -33,8 +33,7 @@ class SkSmallAllocator : SkNoncopyable {
public:
SkSmallAllocator()
: fStorageUsed(0)
- , fNumObjects(0)
- {}
mtklein_C 2016/11/06 13:25:16 Seems unnecessary?
herb_g 2016/11/07 04:44:40 Done.
+ , fNumObjects(0) { }
~SkSmallAllocator() {
// Destruct in reverse order, in case an earlier object points to a
@@ -56,12 +55,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)...);
}
/*
@@ -116,6 +115,7 @@ public:
}
private:
+ static constexpr size_t kAlignment = 16UL;
mtklein_C 2016/11/06 13:25:16 Unused?
herb_g 2016/11/07 04:44:40 Done.
struct Rec {
size_t fStorageSize; // 0 if allocated on heap
void* fObj;
@@ -130,10 +130,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