diff options
author | Richard Hughes <richard@hughsie.com> | 2010-03-17 17:04:50 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2010-03-17 17:04:50 +0000 |
commit | 77db664167c406afea590526bc0762241c02fb44 (patch) | |
tree | 6038122d16e8d92cc8e47ed20ef390b988b6b517 /lib | |
parent | 3fe8ab433623faf5f40681e06ebc9d4fbefcd64b (diff) |
trivial: use the const package data to reduce the number of g_strdup and g_free's we do when sorting a large list of packages
Diffstat (limited to 'lib')
-rw-r--r-- | lib/packagekit-glib2/pk-package-sack.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/lib/packagekit-glib2/pk-package-sack.c b/lib/packagekit-glib2/pk-package-sack.c index af61ed699..aac9b4ea0 100644 --- a/lib/packagekit-glib2/pk-package-sack.c +++ b/lib/packagekit-glib2/pk-package-sack.c @@ -379,17 +379,11 @@ pk_package_sack_sort_compare_package_id_func (PkPackage **a, PkPackage **b) static gint pk_package_sack_sort_compare_summary_func (PkPackage **a, PkPackage **b) { - gint retval; - gchar *summary1; - gchar *summary2; - - g_object_get (*a, "summary", &summary1, NULL); - g_object_get (*b, "summary", &summary2, NULL); - retval = g_strcmp0 (summary1, summary2); - - g_free (summary1); - g_free (summary2); - return retval; + const gchar *summary1; + const gchar *summary2; + summary1 = pk_package_get_summary (*a); + summary2 = pk_package_get_summary (*b); + return g_strcmp0 (summary1, summary2); } /** @@ -398,12 +392,10 @@ pk_package_sack_sort_compare_summary_func (PkPackage **a, PkPackage **b) static gint pk_package_sack_sort_compare_info_func (PkPackage **a, PkPackage **b) { - PkInfoEnum *info1; - PkInfoEnum *info2; - - g_object_get (*a, "info", &info1, NULL); - g_object_get (*b, "info", &info2, NULL); - + PkInfoEnum info1; + PkInfoEnum info2; + info1 = pk_package_get_info (*a); + info2 = pk_package_get_info (*b); if (info1 == info2) return 0; else if (info1 > info2) |