diff --git a/src/common/tvgArray.h b/src/common/tvgArray.h index 08eb2532..3542b2ea 100644 --- a/src/common/tvgArray.h +++ b/src/common/tvgArray.h @@ -38,6 +38,11 @@ struct Array Array(){} + Array(int32_t size) + { + reserve(size); + } + Array(const Array& rhs) { reset(); diff --git a/src/loaders/lottie/tvgLottieBuilder.cpp b/src/loaders/lottie/tvgLottieBuilder.cpp index 0e58ab33..22bd5c86 100644 --- a/src/loaders/lottie/tvgLottieBuilder.cpp +++ b/src/loaders/lottie/tvgLottieBuilder.cpp @@ -329,8 +329,7 @@ static void _repeat(LottieGroup* parent, unique_ptr path, RenderContext* { auto repeater = ctx->repeater; - Array shapes; - shapes.reserve(repeater->cnt); + Array shapes(repeater->cnt); for (int i = 0; i < repeater->cnt; ++i) { auto multiplier = repeater->offset + static_cast(i); diff --git a/src/loaders/lottie/tvgLottieModel.h b/src/loaders/lottie/tvgLottieModel.h index 68263c4a..f8bde603 100644 --- a/src/loaders/lottie/tvgLottieModel.h +++ b/src/loaders/lottie/tvgLottieModel.h @@ -85,13 +85,10 @@ struct LottieGradient uint32_t populate(ColorStop& color) { uint32_t alphaCnt = (color.input->count - (colorStops.count * 4)) / 2; - Array output; - output.reserve(colorStops.count + alphaCnt); - + Array output(colorStops.count + alphaCnt); uint32_t cidx = 0; //color count uint32_t clast = colorStops.count * 4; uint32_t aidx = clast; //alpha count - Fill::ColorStop cs; //merge color stops. diff --git a/src/loaders/lottie/tvgLottieParser.cpp b/src/loaders/lottie/tvgLottieParser.cpp index e665f7fd..4c852820 100644 --- a/src/loaders/lottie/tvgLottieParser.cpp +++ b/src/loaders/lottie/tvgLottieParser.cpp @@ -237,8 +237,7 @@ void LottieParser::getValue(ColorStop& color) { if (peekType() == kArrayType) enterArray(); - color.input = new Array; - color.input->reserve(context->gradient->colorStops.count); + color.input = new Array(context->gradient->colorStops.count); while (nextArrayValue()) color.input->push(getFloat()); } diff --git a/src/renderer/gl_engine/tvgGlRenderer.cpp b/src/renderer/gl_engine/tvgGlRenderer.cpp index 910a6d20..375a33cc 100644 --- a/src/renderer/gl_engine/tvgGlRenderer.cpp +++ b/src/renderer/gl_engine/tvgGlRenderer.cpp @@ -622,8 +622,7 @@ GlRenderPass* GlRenderer::currentPass() void GlRenderer::prepareCmpTask(GlRenderTask* task, float opacity) { // we use 1:1 blit mapping since compositor fbo is same size as root fbo - Array vertices; - vertices.reserve(5 * 4); + Array vertices(5 * 4); float left = -1.f; float top = 1.f; @@ -655,8 +654,7 @@ void GlRenderer::prepareCmpTask(GlRenderTask* task, float opacity) vertices.push(1.f); vertices.push(0.f); - Array indices; - indices.reserve(6); + Array indices(6); indices.push(0); indices.push(1); diff --git a/src/renderer/tvgScene.h b/src/renderer/tvgScene.h index 8ae2055e..518571e6 100644 --- a/src/renderer/tvgScene.h +++ b/src/renderer/tvgScene.h @@ -123,8 +123,7 @@ struct Scene::Impl this->renderer = &renderer; if (clipper) { - Array rds; - rds.reserve(paints.size()); + Array rds(paints.size()); for (auto paint : paints) { rds.push(paint->pImpl->update(renderer, transform, clips, opacity, flag, true)); } diff --git a/src/savers/tvg/tvgTvgSaver.cpp b/src/savers/tvg/tvgTvgSaver.cpp index 682ae28b..bea88446 100644 --- a/src/savers/tvg/tvgTvgSaver.cpp +++ b/src/savers/tvg/tvgTvgSaver.cpp @@ -683,8 +683,7 @@ TvgBinCounter TvgSaver::serializeChildren(Iterator* it, const Matrix* pTransform TvgBinCounter cnt = 0; //Merging shapes. the result is written in the children. - Array children; - children.reserve(it->count()); + Array children(it->count()); children.push(it->next()); while (auto child = it->next()) {