Change db path type 17/319417/1
authorpjh9216 <jh9216.park@samsung.com>
Wed, 23 Oct 2024 01:55:47 +0000 (10:55 +0900)
committerpjh9216 <jh9216.park@samsung.com>
Wed, 23 Oct 2024 01:59:05 +0000 (10:59 +0900)
- We don't need to make a string object any more to open db
- Requires:
  https://review.tizen.org/gerrit/#/c/platform/core/base/bundle/+/319416/

Change-Id: I488a37b0a5810da7c412d7bbd9d3bfe86db9b76a
Signed-off-by: pjh9216 <jh9216.park@samsung.com>
parser/lib/widget_plugin_parser_db.cc
src/widget_service_internal.cc

index 71b1d486b9978e6ca586126665db3aba2e27b41e..ed3458c6f7ae0d14ff4287114258ee1e6b49d45a 100644 (file)
@@ -129,10 +129,10 @@ const char* GetDbPath(uid_t uid) {
 namespace widget_service::parser {
 
 int WidgetPluginParser::Insert(const std::string& pkgid) {
-  std::string path = GetDbPath(GetTargetUid());
+  const auto* path = GetDbPath(GetTargetUid());
 
-  if (access(path.c_str(), F_OK) == -1) {
-    LOGD("db(%s) does not exist, create one", path.c_str());
+  if (access(path, F_OK) == -1) {
+    LOGD("db(%s) does not exist, create one", path);
     return -1;
   }
 
@@ -160,10 +160,10 @@ int WidgetPluginParser::Insert(const std::string& pkgid) {
 }
 
 int WidgetPluginParser::Remove(const std::string& pkgid) {
-  std::string path = GetDbPath(GetTargetUid());
+  const auto* path = GetDbPath(GetTargetUid());
 
-  if (access(path.c_str(), F_OK) == -1) {
-    LOGD("db(%s) does not exist, create one", path.c_str());
+  if (access(path, F_OK) == -1) {
+    LOGD("db(%s) does not exist, create one", path);
     return -1;
   }
 
index 7466f0682126f052e54efe7d698fa7d3671c8ea0..03ea8402537b4656d49277f905f8484c905691ff 100644 (file)
@@ -74,16 +74,16 @@ const char* GetDbPath(uid_t uid) {
 
 std::string GetPreviewPath(std::string widget_id,
         std::string size_type, uid_t uid) {
-  std::string path = GetDbPath(uid);
+  const auto* path = GetDbPath(uid);
   std::string preview_path;
 
-  if (access(path.c_str(), F_OK) == -1) {
-    LOGD("db(%s) does not exist, create one", path.c_str());
+  if (access(path, F_OK) == -1) {
+    LOGD("db(%s) does not exist, create one", path);
     return "";
   }
 
   try {
-    tizen_base::Database db(std::move(path), SQLITE_OPEN_READONLY, BusyHandler);
+    tizen_base::Database db(path, SQLITE_OPEN_READONLY, BusyHandler);
 
     auto q = tizen_base::Database::Sql(
         "SELECT preview FROM support_size WHERE "
@@ -106,16 +106,16 @@ std::string GetPreviewPath(std::string widget_id,
 
 std::vector<WidgetInfo::SupportSize> GetSupportedSizes(
     uid_t uid, std::string widget_id) {
-  std::string path = GetDbPath(uid);
+  const auto* path = GetDbPath(uid);
   std::vector<WidgetInfo::SupportSize> sizes;
 
-  if (access(path.c_str(), F_OK) == -1) {
-    LOGD("db(%s) does not exist, create one", path.c_str());
+  if (access(path, F_OK) == -1) {
+    LOGD("db(%s) does not exist, create one", path);
     throw std::exception();
   }
 
   try {
-    tizen_base::Database db(std::move(path), SQLITE_OPEN_READONLY, BusyHandler);
+    tizen_base::Database db(path, SQLITE_OPEN_READONLY, BusyHandler);
 
     auto q = tizen_base::Database::Sql(
         "SELECT * FROM support_size WHERE classid=?")