fix: use std::make_shared in simple cases to reduce allocation

This commit is contained in:
shenleban tongying 2022-08-23 05:24:33 -04:00
parent d00ea4e420
commit 32b74f2ac2
3 changed files with 7 additions and 3 deletions

View File

@ -32,6 +32,7 @@
#include <QFileDialog>
#include <QUrl>
#include <QSettings>
#include <memory>
#include "rcldb.h"
#include "rclconfig.h"
@ -100,7 +101,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

@ -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

@ -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;