summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-09-03 21:16:29 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2020-09-03 21:16:29 +0200
commit9b94940251ac7cdb5c833c44fa069f978ac706ff (patch)
treeead577d9120d53b6dd673d618d6f4e2756a60835
parent8272d00b506a7357b4b127ef63b53586f2aa751f (diff)
Reduce allocations
-rw-r--r--blurhash.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/blurhash.cpp b/blurhash.cpp
index 03ec39c3..a4adf89f 100644
--- a/blurhash.cpp
+++ b/blurhash.cpp
@@ -260,6 +260,7 @@ decode(std::string_view blurhash, size_t width, size_t height, size_t bytesPerPi
Components components{};
std::vector<Color> values;
+ values.reserve(blurhash.size() / 2);
try {
components = unpackComponents(decode83(blurhash.substr(0, 1)));
@@ -277,7 +278,7 @@ decode(std::string_view blurhash, size_t width, size_t height, size_t bytesPerPi
return {};
}
- i.image.reserve(height * width * 3);
+ i.image.reserve(height * width * bytesPerPixel);
for (size_t y = 0; y < height; y++) {
for (size_t x = 0; x < width; x++) {