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 {
vector<string> tl = g_dynconf->getStringEntries<vector>(asbdSk);
for (const auto& dbd: tl) {
prefs.asearchSubdirHist.push_back(u8s2qs(dbd.c_str()));
prefs.asearchSubdirHist.push_back(u8s2qs(dbd));
}
}
if (!writing) {

View File

@ -26,12 +26,11 @@
#include <qthread.h>
#include <qmessagebox.h>
#include <qcheckbox.h>
#include <qcombobox.h>
#include <QLocale>
#include <QLibraryInfo>
#include <QFileDialog>
#include <QUrl>
#include <QSettings>
#include <memory>
#include "rcldb.h"
#include "rclconfig.h"
@ -100,7 +99,7 @@ bool maybeOpenDb(string &reason, bool force, bool *maindberror)
LOGDEB1("maybeOpenDb: force " << force << "\n");
if (force || nullptr == rcldb) {
rcldb = std::shared_ptr<Rcl::Db>(new Rcl::Db(theconfig));
rcldb = std::make_shared<Rcl::Db>(theconfig);
}
rcldb->rmQueryDb("");
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()));
bool canGetRawText = rcldb && rcldb->storesDocText();
auto it = prefs.preferStoredTextMimes.find(idoc.mimetype);
bool preferStoredText = (it != prefs.preferStoredTextMimes.end());
bool preferStoredText = std::find(prefs.preferStoredTextMimes.begin(),
prefs.preferStoredTextMimes.end(),
idoc.mimetype) != prefs.preferStoredTextMimes.end();
bool loadok{false};
if (!preferStoredText || !canGetRawText) {

View File

@ -22,6 +22,7 @@
#include <QMessageBox>
#include <QSettings>
#include <memory>
#include "qxtconfirmationmessage.h"
@ -75,7 +76,7 @@ void RclMain::viewUrl()
Rcl::Query *query = new Rcl::Query(rcldb.get());
DocSequenceDb *src = new DocSequenceDb(
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);

View File

@ -54,7 +54,7 @@ inline std::string qs2u8s(const QString& qs)
{
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());
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -50,7 +50,7 @@ bool StopList::setFile(const string &filename)
// faster than find() in this case.
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();
}
}