lottie: fixed inefficiency using clang-tidy performance option. 57/188257/1
authorsubhransu mohanty <sub.mohanty@samsung.com>
Mon, 3 Sep 2018 10:10:44 +0000 (19:10 +0900)
committersubhransu mohanty <sub.mohanty@samsung.com>
Mon, 3 Sep 2018 10:10:44 +0000 (19:10 +0900)
Change-Id: I7fc33842e177091a596f980b87759a1cb90ed79e

src/lottie/lottieloader.cpp
src/lottie/lottiemodel.cpp
src/lottie/lottieparser.cpp

index a948e4a..e819e3c 100644 (file)
@@ -35,7 +35,7 @@ std::shared_ptr<LOTModel> LottieFileCache::find(std::string &key)
 
 void LottieFileCache::add(std::string &key, std::shared_ptr<LOTModel> value)
 {
-    mHash[key] = value;
+    mHash[key] = std::move(value);
 }
 
 bool LottieLoader::load(std::string &path)
index 7c75c07..bbbaba2 100644 (file)
@@ -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) {
index 5a0b05f..90be955 100644 (file)
@@ -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<LOTData> 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<LOTData> 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<LOTLayerData *>(obj);