Use move bundle when creating theme object 78/239978/6
authorSangyoon Jang <jeremy.jang@samsung.com>
Fri, 31 Jul 2020 07:32:43 +0000 (16:32 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Fri, 21 Aug 2020 06:39:16 +0000 (15:39 +0900)
bundle may contain large data, we need to re-use this bundle for memory
optimization.

Change-Id: I91bd32d3c3943e4e76deca606cb4ca1f4f2276b6
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
src/theme/loader/theme_info.cc
src/theme/loader/theme_info.h
src/theme_plugin/theme_info_builder.cc
src/theme_provider/package_event_request_handler.cc

index 7173fa0..e43e019 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <algorithm>
 #include <string>
+#include <utility>
 #include <vector>
 
 #include "theme/utils/logging.h"
@@ -49,9 +50,7 @@ std::string GetPkgRootPath(const std::string& pkgid, uid_t uid) {
 namespace ttm {
 namespace loader {
 
-ThemeInfo::ThemeInfo(const tizen_base::Bundle& bundle) {
-  bundle_ = tizen_base::Bundle(bundle);
-}
+ThemeInfo::ThemeInfo(tizen_base::Bundle bundle) : bundle_(std::move(bundle)) { }
 
 bool ThemeInfo::IsValid() const noexcept {
   return !bundle_.IsEmpty();
index d2be2b8..734b5ca 100644 (file)
@@ -31,7 +31,7 @@ namespace loader {
 class ThemeInfo {
  public:
   ThemeInfo() { }
-  explicit ThemeInfo(const tizen_base::Bundle& bundle);
+  explicit ThemeInfo(tizen_base::Bundle bundle);
 
   bool IsValid() const noexcept;
   std::string GetId() const;
index b634553..0678ab0 100644 (file)
@@ -39,7 +39,7 @@ ThemeInfoBuilder& ThemeInfoBuilder::PutStringArray(const std::string& key,
 }
 
 loader::ThemeInfo ThemeInfoBuilder::Build() {
-  return loader::ThemeInfo(bundle_);
+  return loader::ThemeInfo(std::move(bundle_));
 }
 
 void ThemeInfoBuilder::GenerateFileKey(const std::string& root) {
index 7eeebe7..d41436c 100644 (file)
@@ -24,7 +24,7 @@ tizen_base::Bundle PackageEventRequestHandler::OnRequest(dbus::Command cmd,
     return b;
   }
 
-  loader::ThemeInfo theme(args);
+  loader::ThemeInfo theme(std::move(args));
   switch (cmd) {
     case dbus::Command::ADD: {
       result = InstallTheme(theme);