summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Hartwig <mandyke@gmail.com>2012-03-18 01:57:35 +0800
committerDaniel Hartwig <mandyke@gmail.com>2012-03-18 02:13:30 +0800
commit8816b403bafc22d87f202733f283f2b6f83a49fa (patch)
tree7d15b3d4f38d500bc8bb41bf79dd778a4b714d1a
parent12f8292d8b46d1dbd51c6b87d478ad589951b8c3 (diff)
downloadaptitude-8816b403bafc22d87f202733f283f2b6f83a49fa.tar.gz
Restore 3-way compare to pkg_sortpolicy.cc
Recent commit using pkg_name_lt was an oversight. There are a couple of places that use the 3-way compare of sort policies, ideally they should be eliminated in favour of a straight less-than. This would permit further with performance benefits, such as eliminating the pkg_sortpolicy_wrapper.
-rw-r--r--src/pkg_sortpolicy.cc13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/pkg_sortpolicy.cc b/src/pkg_sortpolicy.cc
index 7161b258..bb0578ae 100644
--- a/src/pkg_sortpolicy.cc
+++ b/src/pkg_sortpolicy.cc
@@ -120,11 +120,20 @@ int pkg_sortpolicy_wrapper::compare(cw::treeitem *item1,
return 0; // punt!
}
-static pkg_name_lt plt;
+// TODO: Make these compare functions a simple less-than. Only a
+// couple of places rely on these being able to do 3-way compare.
+// By-name sorting could then reuse pkg_name_lt.
// by-name sorting (including architecture)
PKG_SORTPOLICY_SUBCLASS(pkg_sortpolicy_name,
- return plt(pkg1, pkg2););
+ int cmp = strcmp(pkg1.Name(), pkg2.Name());
+ if(cmp == 0)
+ {
+ cmp = get_arch_order(pkg1.Arch()) - get_arch_order(pkg2.Arch());
+ if(cmp == 0)
+ cmp = strcmp(pkg1.Arch(), pkg2.Arch());
+ }
+ return cmp;);
// installed-size-sorting, treats virtual packages as 0-size
PKG_SORTPOLICY_SUBCLASS(pkg_sortpolicy_installed_size,