Change codes for performance
[platform/core/appfw/pkgmgr-info.git] / src / pkgmgrinfo_db.c
index 27ea246..0ead442 100644 (file)
@@ -205,17 +205,17 @@ API char *getUserPkgParserDBPathUID(uid_t uid)
        }
        snprintf(pkgmgr_parser_db, sizeof(pkgmgr_parser_db),
                        "%s/.pkgmgr_parser.db", db_path);
-
-       if (uid != GLOBAL_USER && uid != ROOT_UID) {
-               tzplatform_set_user(uid);
-               gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
-               tzplatform_reset_user();
+       if (access(db_path, F_OK) != 0) {
+               if (uid != GLOBAL_USER && uid != ROOT_UID) {
+                       tzplatform_set_user(uid);
+                       gid = _get_gid(tzplatform_getenv(TZ_SYS_USER_GROUP));
+                       tzplatform_reset_user();
+               }
+               /* just allow certain users to create the dbspace directory if needed. */
+               if (uid_caller == ROOT_UID || uid_caller == APPFW_UID ||
+                               uid_caller == uid)
+                       _mkdir_for_user(db_path, uid, gid);
        }
-
-       /* just allow certain users to create the dbspace directory if needed. */
-       if (uid_caller == ROOT_UID  || uid_caller == APPFW_UID || uid_caller == uid)
-               _mkdir_for_user(db_path, uid, gid);
-
        free(db_path);
 
        return strdup(pkgmgr_parser_db);
@@ -426,7 +426,7 @@ void _save_column_int(sqlite3_stmt *stmt, int idx, int *i)
        *i = sqlite3_column_int(stmt, idx);
 }
 
-void _save_column_str(sqlite3_stmt *stmt, int idx, char **str)
+inline void _save_column_str(sqlite3_stmt *stmt, int idx, char **str)
 {
        const char *val;