Skip initializing the PNG pixel array

We are about to set all of the pixels anyway
This commit is contained in:
ISSOtm
2022-03-06 10:44:16 +01:00
committed by Eldred Habert
parent ad07c9deb9
commit d675523e49

View File

@@ -69,7 +69,7 @@ class Png {
// These are cached for speed // These are cached for speed
uint32_t width, height; uint32_t width, height;
std::vector<Rgba> pixels; DefaultInitVec<Rgba> pixels;
ImagePalette colors; ImagePalette colors;
int colorType; int colorType;
int nbColors; int nbColors;
@@ -206,8 +206,6 @@ public:
if (height % 8 != 0) if (height % 8 != 0)
fatal("Image height (%" PRIu32 " pixels) is not a multiple of 8!", height); fatal("Image height (%" PRIu32 " pixels) is not a multiple of 8!", height);
// TODO: use an allocator that doesn't zero on init to save potentially a lot of perf
// https://stackoverflow.com/questions/21028299/is-this-behavior-of-vectorresizesize-type-n-under-c11-and-boost-container/21028912#21028912
pixels.resize(static_cast<size_t>(width) * static_cast<size_t>(height)); pixels.resize(static_cast<size_t>(width) * static_cast<size_t>(height));
auto colorTypeName = [this]() { auto colorTypeName = [this]() {