diff --git a/rtgui/filebrowser.cc b/rtgui/filebrowser.cc index c026b63a8..d3fc71d62 100644 --- a/rtgui/filebrowser.cc +++ b/rtgui/filebrowser.cc @@ -600,13 +600,18 @@ void FileBrowser::addEntry_ (FileBrowserEntry* entry) { MYWRITERLOCK(l, entryRW); - std::vector::iterator i = fd.begin(); - - while (i != fd.end() && *entry < * ((FileBrowserEntry*)*i)) { - ++i; - } - - fd.insert (i, entry); + fd.insert( + std::lower_bound( + fd.begin(), + fd.end(), + (ThumbBrowserEntryBase*)entry, + [](ThumbBrowserEntryBase* a, ThumbBrowserEntryBase* b) + { + return *b < *a; + } + ), + (ThumbBrowserEntryBase*)entry + ); initEntry (entry); }