From c90046db13487ccbccfaedc837808b57174bb536 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=B6ssie?= Date: Mon, 10 Jul 2017 21:17:42 +0200 Subject: [PATCH] Use `Glib::ustring::collate_key()` for `ThumbBrowserEntryBase::operator<()` Kudos to @heckflosse for having a nose for optimizations. :+1: Also kills unused `DirEntry` class. --- rtgui/filecatalog.h | 14 ------- rtgui/thumbbrowserentrybase.cc | 72 ++++++++++++++++++++++++++-------- rtgui/thumbbrowserentrybase.h | 5 ++- 3 files changed, 60 insertions(+), 31 deletions(-) diff --git a/rtgui/filecatalog.h b/rtgui/filecatalog.h index 5116f3bb3..29e4a370a 100644 --- a/rtgui/filecatalog.h +++ b/rtgui/filecatalog.h @@ -36,20 +36,6 @@ #include "multilangmgr.h" #include "threadutils.h" - -class DirEntry -{ - -public: - Glib::ustring fullName; - - explicit DirEntry (const Glib::ustring& n) : fullName (n) {} - - bool operator< (DirEntry& other) - { - return fullName.casefold() < other.fullName.casefold(); - } -}; class FilePanel; /* * Class: diff --git a/rtgui/thumbbrowserentrybase.cc b/rtgui/thumbbrowserentrybase.cc index cf0ce1bb3..ff7e58d49 100644 --- a/rtgui/thumbbrowserentrybase.cc +++ b/rtgui/thumbbrowserentrybase.cc @@ -17,33 +17,73 @@ * along with RawTherapee. If not, see . */ #include "thumbbrowserentrybase.h" -#include "thumbbrowserbase.h" + #include "options.h" +#include "thumbbrowserbase.h" + #include "../rtengine/mytime.h" -ThumbBrowserEntryBase::ThumbBrowserEntryBase (const Glib::ustring& fname) - : fnlabw(0), fnlabh(0), dtlabw(0), dtlabh(0), exlabw(0), exlabh(0), prew(0), preh(0), - prex(0), prey(0), upperMargin(6), borderWidth(1), textGap(6), sideMargin(8), lowerMargin(8), - preview(nullptr), dispname(Glib::path_get_basename (fname)), buttonSet(nullptr), width(0), height(0), - exp_width(0), exp_height(0), startx(0), starty(0), ofsX(0), ofsY(0), redrawRequests(0), - parent(nullptr), original(nullptr), bbSelected(false), bbFramed(false), bbPreview(nullptr), cursor_type(CSUndefined), - thumbnail(nullptr), filename(fname), shortname(dispname), exifline(""), datetimeline(""), - selected(false), drawable(false), filtered(false), framed(false), processing(false), italicstyle(false), - edited(false), recentlysaved(false), updatepriority(false), withFilename(WFNAME_NONE) {} +ThumbBrowserEntryBase::ThumbBrowserEntryBase (const Glib::ustring& fname) : + fnlabw(0), + fnlabh(0), + dtlabw(0), + dtlabh(0), + exlabw(0), + exlabh(0), + prew(0), + preh(0), + prex(0), + prey(0), + upperMargin(6), + borderWidth(1), + textGap(6), + sideMargin(8), + lowerMargin(8), + preview(nullptr), + dispname(Glib::path_get_basename(fname)), + buttonSet(nullptr), + width(0), + height(0), + exp_width(0), + exp_height(0), + startx(0), + starty(0), + ofsX(0), + ofsY(0), + redrawRequests(0), + parent(nullptr), + original(nullptr), + bbSelected(false), + bbFramed(false), + bbPreview(nullptr), + cursor_type(CSUndefined), + collate_name(dispname.casefold().collate_key()), + thumbnail(nullptr), + filename(fname), + shortname(dispname), + exifline(""), + datetimeline(""), + selected(false), + drawable(false), + filtered(false), + framed(false), + processing(false), + italicstyle(false), + edited(false), + recentlysaved(false), + updatepriority(false), + withFilename(WFNAME_NONE) +{ +} ThumbBrowserEntryBase::~ThumbBrowserEntryBase () { - - if (preview) { - delete [] preview; - } - + delete[] preview; delete buttonSet; } void ThumbBrowserEntryBase::addButtonSet (LWButtonSet* bs) { - buttonSet = bs; } diff --git a/rtgui/thumbbrowserentrybase.h b/rtgui/thumbbrowserentrybase.h index 55d7179ab..f4779faa1 100644 --- a/rtgui/thumbbrowserentrybase.h +++ b/rtgui/thumbbrowserentrybase.h @@ -88,6 +88,9 @@ protected: // called during updateBackBuffer for custom overlays virtual void customBackBufferUpdate (Cairo::RefPtr c) {} +private: + const std::string collate_name; + public: Thumbnail* thumbnail; @@ -169,7 +172,7 @@ public: bool operator <(const ThumbBrowserEntryBase& other) const { - return shortname.casefold() < other.shortname.casefold(); + return collate_name < other.collate_name; } ThumbBrowserEntryBase* getOriginal () const;