Max Bowsher wrote: > Robert Collins wrote: > > Much better. Please supply as a attachment, along with a changelog.
Here. > > > + set<String, String::caseless>::const_iterator all = > categories.find("All"); > > this is also not needed, and if we were using something that supports > > multiple entries (say a vector) with the same key, would give incorrect > > results. > > My gut feeling was that an iterator should compare quicker than a string. I did some speed testing - I was wrong, it turns out. It turns out that my weird attempt at making thinks faster actually made things _slower_. The patch is therefore remodelled. Max.
ChangeLog-fragment
Description: Binary data
Index: PickPackageLine.cc =================================================================== RCS file: /home/max/cvsmirror/cygwin-apps-cvs/setup/PickPackageLine.cc,v retrieving revision 2.9 diff -u -p -r2.9 PickPackageLine.cc --- PickPackageLine.cc 2002/07/13 14:00:37 2.9 +++ PickPackageLine.cc 2002/09/19 21:03:55 @@ -136,14 +136,10 @@ PickPackageLine::paint (HDC hdc, int x, /* shows "first" category - do we want to show any? */ if (pkg.categories.size () && show_cat) { - String catName; - if (pkg.categories.find ("All") == pkg.categories.begin () && - pkg.categories.size () > 1) - catName = *(++pkg.categories.begin()); - else catName = * pkg.categories.begin (); + String catName = pkg.getReadableCategoryList(); IntersectClipRect (hdc, x + theView.headers[theView.cat_col].x, r, x + theView.headers[theView.cat_col].x + - theView.headers[theView.cat_col].x, rb); + theView.headers[theView.cat_col].width - HMARGIN / 2, rb); TextOut (hdc, x + theView.headers[theView.cat_col].x + HMARGIN / 2, r, catName.cstr_oneuse(), catName.size()); Index: PickView.cc =================================================================== RCS file: /home/max/cvsmirror/cygwin-apps-cvs/setup/PickView.cc,v retrieving revision 2.10 diff -u -p -r2.10 PickView.cc --- PickView.cc 2002/07/09 06:57:40 2.10 +++ PickView.cc 2002/09/19 21:28:43 @@ -29,7 +29,7 @@ static PickView::Header pkg_headers[] = {"New", 3, 0, 0}, {"Bin?", 4, 0, 0}, {"Src?", 4, 0, 0}, - {"Category", 8, 0, 0}, + {"Categories", 10, 0, 0}, {"Package", 7, 0, 0}, {0, 0, 0, 0} }; Index: package_meta.cc =================================================================== RCS file: /home/max/cvsmirror/cygwin-apps-cvs/setup/package_meta.cc,v retrieving revision 2.31 diff -u -p -r2.31 package_meta.cc --- package_meta.cc 2002/07/13 14:00:37 2.31 +++ package_meta.cc 2002/09/22 19:29:09 @@ -241,6 +241,22 @@ packagemeta::add_category (String const categories.insert (cat); } +String const +packagemeta::getReadableCategoryList () const +{ + String result; + for(set<String, String::caseless>::const_iterator it = categories.begin(); + it != categories.end(); it++) + { + if (*it == "All") + continue; + if (result.size() > 0) + result += ", "; + result += *it; + } + return result; +} + static bool hasSDesc(packageversion const &pkg) { Index: package_meta.h =================================================================== RCS file: /home/max/cvsmirror/cygwin-apps-cvs/setup/package_meta.h,v retrieving revision 2.19 diff -u -p -r2.19 package_meta.h --- package_meta.h 2002/07/07 15:14:50 2.19 +++ package_meta.h 2002/09/19 14:32:08 @@ -96,6 +96,7 @@ public: */ void add_category (String const &); set <String, String::caseless> categories; + String const getReadableCategoryList () const; set <packageversion> versions; /* which one is installed. */