Merge branch 'master' into 'master'

a bunch of micro-optimizations

See merge request medoc92/recoll!9
This commit is contained in:
Jean-Francois Dockes 2022-08-24 05:43:36 +00:00
commit c1bec06711
11 changed files with 16 additions and 16 deletions

View File

@ -416,7 +416,7 @@ void rwSettings(bool writing)
} else { } else {
vector<string> tl = g_dynconf->getStringEntries<vector>(asbdSk); vector<string> tl = g_dynconf->getStringEntries<vector>(asbdSk);
for (const auto& dbd: tl) { for (const auto& dbd: tl) {
prefs.asearchSubdirHist.push_back(u8s2qs(dbd.c_str())); prefs.asearchSubdirHist.push_back(u8s2qs(dbd));
} }
} }
if (!writing) { if (!writing) {

View File

@ -26,12 +26,11 @@
#include <qthread.h> #include <qthread.h>
#include <qmessagebox.h> #include <qmessagebox.h>
#include <qcheckbox.h> #include <qcheckbox.h>
#include <qcombobox.h>
#include <QLocale> #include <QLocale>
#include <QLibraryInfo> #include <QLibraryInfo>
#include <QFileDialog> #include <QFileDialog>
#include <QUrl> #include <QUrl>
#include <QSettings> #include <memory>
#include "rcldb.h" #include "rcldb.h"
#include "rclconfig.h" #include "rclconfig.h"
@ -100,7 +99,7 @@ bool maybeOpenDb(string &reason, bool force, bool *maindberror)
LOGDEB1("maybeOpenDb: force " << force << "\n"); LOGDEB1("maybeOpenDb: force " << force << "\n");
if (force || nullptr == rcldb) { if (force || nullptr == rcldb) {
rcldb = std::shared_ptr<Rcl::Db>(new Rcl::Db(theconfig)); rcldb = std::make_shared<Rcl::Db>(theconfig);
} }
rcldb->rmQueryDb(""); rcldb->rmQueryDb("");
auto edbs = &prefs.activeExtraDbs; auto edbs = &prefs.activeExtraDbs;

View File

@ -782,8 +782,9 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
connect(&lthr, SIGNAL(finished()), &loop, SLOT(quit())); connect(&lthr, SIGNAL(finished()), &loop, SLOT(quit()));
bool canGetRawText = rcldb && rcldb->storesDocText(); bool canGetRawText = rcldb && rcldb->storesDocText();
auto it = prefs.preferStoredTextMimes.find(idoc.mimetype); bool preferStoredText = std::find(prefs.preferStoredTextMimes.begin(),
bool preferStoredText = (it != prefs.preferStoredTextMimes.end()); prefs.preferStoredTextMimes.end(),
idoc.mimetype) != prefs.preferStoredTextMimes.end();
bool loadok{false}; bool loadok{false};
if (!preferStoredText || !canGetRawText) { if (!preferStoredText || !canGetRawText) {

View File

@ -22,6 +22,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QSettings> #include <QSettings>
#include <memory>
#include "qxtconfirmationmessage.h" #include "qxtconfirmationmessage.h"
@ -75,7 +76,7 @@ void RclMain::viewUrl()
Rcl::Query *query = new Rcl::Query(rcldb.get()); Rcl::Query *query = new Rcl::Query(rcldb.get());
DocSequenceDb *src = new DocSequenceDb( DocSequenceDb *src = new DocSequenceDb(
rcldb, std::shared_ptr<Rcl::Query>(query), "", rcldb, std::shared_ptr<Rcl::Query>(query), "",
std::shared_ptr<Rcl::SearchData>(new Rcl::SearchData)); std::make_shared<Rcl::SearchData>());
m_source = std::shared_ptr<DocSequence>(src); m_source = std::shared_ptr<DocSequence>(src);

View File

@ -54,7 +54,7 @@ inline std::string qs2u8s(const QString& qs)
{ {
return std::string((const char *)qs.toUtf8()); return std::string((const char *)qs.toUtf8());
} }
inline QString u8s2qs(const std::string us) inline QString u8s2qs(const std::string& us)
{ {
return QString::fromUtf8(us.c_str()); return QString::fromUtf8(us.c_str());
} }

View File

@ -35,7 +35,6 @@
#include <QStyledItemDelegate> #include <QStyledItemDelegate>
#include <QTextDocument> #include <QTextDocument>
#include <QPainter> #include <QPainter>
#include <QSplitter>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QTimer> #include <QTimer>
@ -488,7 +487,7 @@ void RecollModel::sort(int column, Qt::SortOrder order)
if (!stringlowercmp("date", spec.field) || if (!stringlowercmp("date", spec.field) ||
!stringlowercmp("datetime", spec.field)) !stringlowercmp("datetime", spec.field))
spec.field = "mtime"; spec.field = "mtime";
spec.desc = order == Qt::AscendingOrder ? false : true; spec.desc = (order != Qt::AscendingOrder);
} }
emit sortDataChanged(spec); emit sortDataChanged(spec);
} }

View File

@ -24,7 +24,6 @@
#include <string> #include <string>
#include <QCheckBox>
#include <QMessageBox> #include <QMessageBox>
#include "recoll.h" #include "recoll.h"

View File

@ -218,8 +218,8 @@ void SpellW::doExpand()
resTW->setItem(0, 0, new QTableWidgetItem(tr("No expansion found"))); resTW->setItem(0, 0, new QTableWidgetItem(tr("No expansion found")));
} else { } else {
int row = 0; int row = 0;
// maxexpand is static const, thus guaranteed to be >0
if (maxexpand > 0 && int(res.entries.size()) >= maxexpand) { if (int(res.entries.size()) >= maxexpand) {
resTW->setRowCount(row + 1); resTW->setRowCount(row + 1);
resTW->setSpan(row, 0, 1, 2); resTW->setSpan(row, 0, 1, 2);
resTW->setItem(row++, 0, resTW->setItem(row++, 0,

View File

@ -610,7 +610,6 @@ bool SSearch::fromXML(const SSearchDef& fxml)
if (!checkExtIndexes(fxml.extindexes)) { if (!checkExtIndexes(fxml.extindexes)) {
std::string asString;
stringsToString(fxml.extindexes, asString); stringsToString(fxml.extindexes, asString);
QMessageBox::warning( QMessageBox::warning(
0, "Recoll", 0, "Recoll",

View File

@ -22,6 +22,8 @@
#include "guiutils.h" #include "guiutils.h"
#include "log.h" #include "log.h"
#include "xmltosd.h" #include "xmltosd.h"
#include <memory>
#include "smallut.h" #include "smallut.h"
#include "recoll.h" #include "recoll.h"
#include "picoxml.h" #include "picoxml.h"
@ -51,7 +53,7 @@ public:
} }
resetTemps(); resetTemps();
// A new search descriptor. Allocate data structure // A new search descriptor. Allocate data structure
sd = std::shared_ptr<SearchData>(new SearchData); sd = std::make_shared<SearchData>();
if (!sd) { if (!sd) {
LOGERR("SDHXMLHandler::startElement: out of memory\n"); LOGERR("SDHXMLHandler::startElement: out of memory\n");
contentsOk = false; contentsOk = false;

View File

@ -50,7 +50,7 @@ bool StopList::setFile(const string &filename)
// faster than find() in this case. // faster than find() in this case.
bool StopList::isStop(const string &term) const bool StopList::isStop(const string &term) const
{ {
return m_stops.empty() ? false : m_stops.find(term) != m_stops.end(); return !m_stops.empty() && m_stops.find(term) != m_stops.end();
} }
} }