Change glist add function 02/229602/2
authorJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 2 Apr 2020 07:07:31 +0000 (16:07 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Thu, 16 Apr 2020 07:31:24 +0000 (07:31 +0000)
g_list_append() had to traverse entire list to find the end.
If list doesn't have to be sorted with specific order,
g_list_prepend() will be enough.

Change-Id: I10b9851a8576733d7100b4d2e8564fe8775aada7
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
parser/src/pkgmgr_parser_db.c
src/pkgmgrinfo_appinfo.c
src/pkgmgrinfo_pkginfo.c
src/pkgmgrinfo_plugininfo.c
src/pkgmgrinfo_private.c
tool/pkg-db-recovery.c

index d663aa4..b63af0f 100644 (file)
@@ -1117,7 +1117,7 @@ static void __find_appcontrol_splashscreen_with_dpi(gpointer data,
        if (__check_dpi(ss->dpi, dpi) != 0)
                return;
 
-       *list = g_list_append(*list, ss);
+       *list = g_list_prepend(*list, ss);
 }
 
 static void __find_appcontrol_splashscreen(gpointer data, gpointer user_data)
@@ -1138,7 +1138,7 @@ static void __find_appcontrol_splashscreen(gpointer data, gpointer user_data)
                        return;
        }
 
-       *list = g_list_append(*list, ss);
+       *list = g_list_prepend(*list, ss);
 }
 
 static GList *__find_splashscreens(GList *splashscreens)
@@ -1156,10 +1156,10 @@ static GList *__find_splashscreens(GList *splashscreens)
 
        ss = __find_default_splashscreen(splashscreens, "portrait");
        if (ss)
-               list = g_list_append(list, ss);
+               list = g_list_prepend(list, ss);
        ss = __find_default_splashscreen(splashscreens, "landscape");
        if (ss)
-               list = g_list_append(list, ss);
+               list = g_list_prepend(list, ss);
 
        return list;
 }
index e88018f..c928104 100644 (file)
@@ -147,7 +147,7 @@ static int _appinfo_get_category(sqlite3 *db, const char *appid,
                val = NULL;
                _save_column_str(stmt, 0, &val);
                if (val)
-                       *category = g_list_append(*category, (gpointer)val);
+                       *category = g_list_prepend(*category, (gpointer)val);
        }
 
        sqlite3_finalize(stmt);
@@ -189,7 +189,7 @@ static void __parse_appcontrol(GList **appcontrol, char *appcontrol_str,
                        ac->mime = strdup(token);
                ac->visibility = strdup(visibility);
                ac->id = strdup(id);
-               *appcontrol = g_list_append(*appcontrol, ac);
+               *appcontrol = g_list_prepend(*appcontrol, ac);
        } while ((token = strtok_r(NULL, ";", &ptr)));
 
        free(dup);
@@ -277,7 +277,7 @@ static int _appinfo_get_metadata(sqlite3 *db, const char *appid,
                idx = 0;
                _save_column_str(stmt, idx++, &info->key);
                _save_column_str(stmt, idx++, &info->value);
-               *metadata = g_list_append(*metadata, info);
+               *metadata = g_list_prepend(*metadata, info);
        }
 
        sqlite3_finalize(stmt);
@@ -325,7 +325,7 @@ static int _appinfo_get_splashscreens(sqlite3 *db, const char *appid,
                _save_column_str(stmt, idx++, &info->indicatordisplay);
                _save_column_str(stmt, idx++, &info->operation);
                _save_column_str(stmt, idx++, &info->color_depth);
-               *splashscreens = g_list_append(*splashscreens, info);
+               *splashscreens = g_list_prepend(*splashscreens, info);
        }
 
        sqlite3_finalize(stmt);
@@ -345,30 +345,30 @@ static GList *__get_background_category(const char *value)
                return NULL;
 
        if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
-               category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
+               category_list = g_list_prepend(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
        else
-               category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
+               category_list = g_list_prepend(category_list, strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
 
        if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
-               category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
+               category_list = g_list_prepend(category_list, strdup(APP_BG_CATEGORY_MEDIA_STR));
 
        if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
-               category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
+               category_list = g_list_prepend(category_list, strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
 
        if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
-               category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
+               category_list = g_list_prepend(category_list, strdup(APP_BG_CATEGORY_BGNETWORK_STR));
 
        if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
-               category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
+               category_list = g_list_prepend(category_list, strdup(APP_BG_CATEGORY_LOCATION_STR));
 
        if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
-               category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
+               category_list = g_list_prepend(category_list, strdup(APP_BG_CATEGORY_SENSOR_STR));
 
        if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
-               category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
+               category_list = g_list_prepend(category_list, strdup(APP_BG_CATEGORY_IOTCOMM_STR));
 
        if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
-               category_list = g_list_append(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
+               category_list = g_list_prepend(category_list, strdup(APP_BG_CATEGORY_SYSTEM));
 
        return category_list;
 
index 4235b42..de8bda6 100644 (file)
@@ -176,7 +176,7 @@ static int _pkginfo_add_description_info_into_list(const char *locale,
        }
        info->lang = strdup(locale);
        info->text = record;
-       *description = g_list_append(*description, info);
+       *description = g_list_prepend(*description, info);
 
        return PMINFO_R_OK;
 }
@@ -217,7 +217,7 @@ static int _pkginfo_get_plugin_execution_info(sqlite3 *db, const char *pkgid,
                _save_column_str(stmt, 0, &plugin->appid);
                _save_column_str(stmt, 1, &plugin->plugin_type);
                _save_column_str(stmt, 2, &plugin->plugin_name);
-               *plugins = g_list_append(*plugins,
+               *plugins = g_list_prepend(*plugins,
                                (gpointer)plugin);
        }
 
@@ -260,7 +260,7 @@ static int _pkginfo_get_privilege(sqlite3 *db, const char *pkgid,
                }
                _save_column_str(stmt, 0, &privilege->value);
                _save_column_str(stmt, 1, &privilege->type);
-               *privileges = g_list_append(*privileges,
+               *privileges = g_list_prepend(*privileges,
                                (gpointer)privilege);
        }
 
@@ -304,7 +304,7 @@ static int _pkginfo_get_appdefined_privilege(sqlite3 *db, const char *pkgid,
                _save_column_str(stmt, 0, &privilege->value);
                _save_column_str(stmt, 1, &privilege->license);
                _save_column_str(stmt, 2, &privilege->type);
-               *privileges = g_list_append(*privileges,
+               *privileges = g_list_prepend(*privileges,
                                (gpointer)privilege);
        }
 
@@ -347,7 +347,7 @@ static int _pkginfo_get_dependency(sqlite3 *db, const char *pkgid,
                _save_column_str(stmt, 0, &dependency->depends_on);
                _save_column_str(stmt, 1, &dependency->type);
                _save_column_str(stmt, 2, &dependency->required_version);
-               *dependencies = g_list_append(*dependencies,
+               *dependencies = g_list_prepend(*dependencies,
                                (gpointer)dependency);
        }
 
@@ -631,7 +631,7 @@ static int _pkginfo_get_packages(uid_t uid, const char *locale,
                        _save_column_str(stmt, idx++, &author->text);
                        _save_column_str(stmt, idx++, &author->email);
                        _save_column_str(stmt, idx++, &author->href);
-                       info->author = g_list_append(info->author, author);
+                       info->author = g_list_prepend(info->author, author);
                }
 
                if (flag & PMINFO_PKGINFO_GET_LABEL) {
@@ -2225,7 +2225,7 @@ static int _get_depends_on(sqlite3 *db, const char *pkgid, GQueue **queue,
                _save_column_str(stmt, 2, &req->type);
                _save_column_str(stmt, 3, &req->version);
 
-               *pkg_list = g_list_append(*pkg_list, req);
+               *pkg_list = g_list_prepend(*pkg_list, req);
                g_queue_push_tail(*queue, strdup(req->from));
        }
 
index 4e96dd4..c15a257 100644 (file)
@@ -113,7 +113,7 @@ API int pkgmgrinfo_plugininfo_foreach_plugininfo(const char *pkgid,
                if (appid) {
                        plugin->appid = strdup(appid);
                }
-               plugin_list = g_list_append(plugin_list, plugin);
+               plugin_list = g_list_prepend(plugin_list, plugin);
        }
 
        for (tmp_list = plugin_list; tmp_list != NULL; tmp_list = tmp_list->next) {
index e7a8faf..68f6f36 100644 (file)
@@ -463,7 +463,7 @@ int _add_icon_info_into_list(const char *locale, char *value, GList **icon)
        }
        info->text = value;
        info->lang = strdup(locale);
-       *icon = g_list_append(*icon, info);
+       *icon = g_list_prepend(*icon, info);
 
        return PMINFO_R_OK;
 }
@@ -479,7 +479,7 @@ int _add_label_info_into_list(const char *locale, char *value, GList **label)
        }
        info->text = value;
        info->lang = strdup(locale);
-       *label = g_list_append(*label, info);
+       *label = g_list_prepend(*label, info);
 
        return PMINFO_R_OK;
 }
index 650f3c0..c370b43 100644 (file)
@@ -350,7 +350,7 @@ static void _get_user_list()
 
                info->uid = uid;
                info->db_path = __get_dbpath(uid);
-               user_info_list = g_list_append(user_info_list, info);
+               user_info_list = g_list_prepend(user_info_list, info);
        }
 
        closedir(dir);