From 8288c8cf8376f44a36ff1e7c56c06ff3be9d4c19 Mon Sep 17 00:00:00 2001 From: subhransu mohanty Date: Mon, 3 Sep 2018 19:10:44 +0900 Subject: [PATCH] lottie: fixed inefficiency using clang-tidy performance option. Change-Id: I7fc33842e177091a596f980b87759a1cb90ed79e --- src/lottie/lottieloader.cpp | 2 +- src/lottie/lottiemodel.cpp | 4 ++-- src/lottie/lottieparser.cpp | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/lottie/lottieloader.cpp b/src/lottie/lottieloader.cpp index a948e4a..e819e3c 100644 --- a/src/lottie/lottieloader.cpp +++ b/src/lottie/lottieloader.cpp @@ -35,7 +35,7 @@ std::shared_ptr LottieFileCache::find(std::string &key) void LottieFileCache::add(std::string &key, std::shared_ptr value) { - mHash[key] = value; + mHash[key] = std::move(value); } bool LottieLoader::load(std::string &path) diff --git a/src/lottie/lottiemodel.cpp b/src/lottie/lottiemodel.cpp index 7c75c07..bbbaba2 100644 --- a/src/lottie/lottiemodel.cpp +++ b/src/lottie/lottiemodel.cpp @@ -19,7 +19,7 @@ public: void visit(LOTPolystarData *) override {} void visitChildren(LOTGroupData *obj) override { - for (auto child : obj->mChildren) { + for (const auto& child : obj->mChildren) { child.get()->accept(this); if (mRepeaterFound) { LOTRepeaterData *repeater = @@ -31,7 +31,7 @@ public: // copy all the child of the object till repeater and // move that in to a group and then add that group to // the repeater object. - for (auto cpChild : obj->mChildren) { + for (const auto& cpChild : obj->mChildren) { if (cpChild == child) break; // there shouldn't be any trim object left in the child list if (cpChild.get()->type() == LOTData::Type::Trim) { diff --git a/src/lottie/lottieparser.cpp b/src/lottie/lottieparser.cpp index 5a0b05f..90be955 100644 --- a/src/lottie/lottieparser.cpp +++ b/src/lottie/lottieparser.cpp @@ -533,7 +533,7 @@ VRect LottieParserImpl::getRect() void LottieParserImpl::resolveLayerRefs() { - for (auto i : mLayersToUpdate) { + for (const auto& i : mLayersToUpdate) { LOTLayerData *layer = i.get(); auto search = compRef->mAssets.find(layer->mPreCompRefId); if (search != compRef->mAssets.end()) { @@ -801,11 +801,11 @@ std::shared_ptr LottieParserImpl::parseLayer() } // update the static property of layer bool staticFlag = true; - for (auto child : layer->mChildren) { + for (const auto& child : layer->mChildren) { staticFlag &= child.get()->isStatic(); } - for (auto mask : layer->mMasks) { + for (const auto& mask : layer->mMasks) { staticFlag &= mask->isStatic(); } @@ -955,7 +955,7 @@ std::shared_ptr LottieParserImpl::parseGroupObject() } } bool staticFlag = true; - for (auto child : group->mChildren) { + for (const auto& child : group->mChildren) { staticFlag &= child.get()->isStatic(); } @@ -1923,7 +1923,7 @@ public: } void visitChildren(LOTGroupData *obj) override { - for (auto child : obj->mChildren) child.get()->accept(this); + for (const auto& child : obj->mChildren) child.get()->accept(this); switch (obj->type()) { case LOTData::Type::Layer: { LOTLayerData *layer = static_cast(obj); -- 2.7.4