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

Unified Diff: src/core/SkSmallAllocator.h

Issue 2473143002: Use alignas to force alignment. (Closed)
Patch Set: Remove comment. 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 | « src/core/SkLinearBitmapPipeline.h ('k') | no next file » | 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 9095fa57fc11fde0022c023f5e8341d7dae819dd..67afe756912bdd014945f0ba235dc9797cdc3aa7 100644
--- a/src/core/SkSmallAllocator.h
+++ b/src/core/SkSmallAllocator.h
@@ -93,7 +93,7 @@ public:
// There is space in fStorage.
rec->fStorageSize = storageRequired;
rec->fHeapStorage = nullptr;
- rec->fObj = static_cast<void*>(fStorage.fBytes + fStorageUsed);
+ rec->fObj = static_cast<void*>(fStorage + fStorageUsed);
fStorageUsed += storageRequired;
}
rec->fKillProc = DestroyT<T>;
@@ -129,17 +129,11 @@ private:
static_cast<T*>(ptr)->~T();
}
- struct SK_STRUCT_ALIGN(16) Storage {
- // we add kMaxObjects * 15 to account for the worst-case slop, where each allocation wasted
- // 15 bytes (due to forcing each to be 16-byte aligned)
- char fBytes[kTotalBytes + kMaxObjects * 15];
- };
-
- Storage fStorage;
+ alignas(16) char fStorage[kTotalBytes];
// Number of bytes used so far.
- size_t fStorageUsed;
- uint32_t fNumObjects;
- Rec fRecs[kMaxObjects];
+ size_t fStorageUsed;
+ uint32_t fNumObjects;
+ Rec fRecs[kMaxObjects];
};
#endif // SkSmallAllocator_DEFINED
« no previous file with comments | « src/core/SkLinearBitmapPipeline.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698