Use std[::tr1]::shared_ptr instead of local RefCntr by default

This commit is contained in:
Jean-Francois Dockes
2015-08-09 13:54:24 +02:00
parent 83939e45ab
commit 4d1f679eac
61 changed files with 313 additions and 288 deletions
+5 -5
View File
@@ -21,7 +21,7 @@
#include "debuglog.h"
#include "utf8iter.h"
#include "smallut.h"
#include "refcntr.h"
#include MEMORY_INCLUDE
#include "textsplit.h"
#include "xmacros.h"
#include "rcldb.h"
@@ -56,13 +56,13 @@ bool createExpansionDbs(Xapian::WritableDatabase& wdb,
vector<XapWritableComputableSynFamMember> stemdbs;
// Note: tried to make this to work with stack-allocated objects, couldn't.
// Looks like a bug in copy constructors somewhere, can't guess where
vector<RefCntr<SynTermTransStem> > stemmers;
vector<STD_SHARED_PTR<SynTermTransStem> > stemmers;
for (unsigned int i = 0; i < langs.size(); i++) {
stemmers.push_back(RefCntr<SynTermTransStem>
stemmers.push_back(STD_SHARED_PTR<SynTermTransStem>
(new SynTermTransStem(langs[i])));
stemdbs.push_back(
XapWritableComputableSynFamMember(wdb, synFamStem, langs[i],
stemmers.back().getptr()));
stemmers.back().get()));
stemdbs.back().recreate();
}
@@ -73,7 +73,7 @@ bool createExpansionDbs(Xapian::WritableDatabase& wdb,
for (unsigned int i = 0; i < langs.size(); i++) {
unacstemdbs.push_back(
XapWritableComputableSynFamMember(wdb, synFamStemUnac, langs[i],
stemmers.back().getptr()));
stemmers.back().get()));
unacstemdbs.back().recreate();
}
}
+1 -1
View File
@@ -157,7 +157,7 @@ double Query::Native::qualityTerms(Xapian::docid docid,
if (doclen == 0)
doclen = 1;
HighlightData hld;
if (!m_q->m_sd.isNull()) {
if (m_q->m_sd) {
m_q->m_sd->getTerms(hld);
}
+1 -1
View File
@@ -570,7 +570,7 @@ bool Db::Native::addOrUpdateWrite(const string& udi, const string& uniterm,
Chrono chron;
PTMutexLocker lock(m_mutex);
#endif
RefCntr<Xapian::Document> doc_cleaner(newdocument_ptr);
STD_SHARED_PTR<Xapian::Document> doc_cleaner(newdocument_ptr);
// Check file system full every mbyte of indexed text. It's a bit wasteful
// to do this after having prepared the document, but it needs to be in
+1 -1
View File
@@ -21,9 +21,9 @@
#include <string>
#include <vector>
#include MEMORY_INCLUDE
#include "cstr.h"
#include "refcntr.h"
#include "rcldoc.h"
#include "stoplist.h"
#include "rclconfig.h"
+1 -1
View File
@@ -70,7 +70,7 @@ bool Db::docDups(const Doc& idoc, vector<Doc>& odocs)
MD5HexPrint(digest, md5);
SearchData *sdp = new SearchData();
RefCntr<SearchData> sd(sdp);
STD_SHARED_PTR<SearchData> sd(sdp);
SearchDataClauseSimple *sdc =
new SearchDataClauseSimple(SCLT_AND, md5, "rclmd5");
sdc->addModifier(SearchDataClause::SDCM_CASESENS);
+1 -1
View File
@@ -173,7 +173,7 @@ void Query::setSortBy(const string& fld, bool ascending) {
#define ISNULL(X) !(X)
// Prepare query out of user search data
bool Query::setQuery(RefCntr<SearchData> sdata)
bool Query::setQuery(STD_SHARED_PTR<SearchData> sdata)
{
LOGDEB(("Query::setQuery:\n"));
+4 -4
View File
@@ -19,7 +19,7 @@
#include <string>
#include <vector>
#include "refcntr.h"
#include MEMORY_INCLUDE
#include "searchdata.h"
#ifndef NO_NAMESPACES
@@ -92,7 +92,7 @@ class Query {
* be called repeatedly on the same object which gets reinitialized each
* time.
*/
bool setQuery(RefCntr<SearchData> q);
bool setQuery(STD_SHARED_PTR<SearchData> q);
/** Get results count for current query */
int getResCnt();
@@ -117,7 +117,7 @@ class Query {
int getFirstMatchPage(const Doc &doc, std::string& term);
/** Retrieve a reference to the searchData we are using */
RefCntr<SearchData> getSD()
STD_SHARED_PTR<SearchData> getSD()
{
return m_sd;
}
@@ -143,7 +143,7 @@ private:
bool m_sortAscending;
bool m_collapseDuplicates;
int m_resCnt;
RefCntr<SearchData> m_sd;
STD_SHARED_PTR<SearchData> m_sd;
int m_snipMaxPosWalk;
/* Copyconst and assignement private and forbidden */
+11 -11
View File
@@ -198,11 +198,11 @@ bool Db::termMatch(int typ_sens, const string &lang, const string &_term,
XapComputableSynFamMember synac(xrdb, synFamDiCa, "all", &unacfoldtrans);
if (matchtyp == ET_WILD || matchtyp == ET_REGEXP) {
RefCntr<StrMatcher> matcher;
STD_SHARED_PTR<StrMatcher> matcher;
if (matchtyp == ET_WILD) {
matcher = RefCntr<StrMatcher>(new StrWildMatcher(term));
matcher = STD_SHARED_PTR<StrMatcher>(new StrWildMatcher(term));
} else {
matcher = RefCntr<StrMatcher>(new StrRegexpMatcher(term));
matcher = STD_SHARED_PTR<StrMatcher>(new StrRegexpMatcher(term));
}
if (!diac_sensitive || !case_sensitive) {
// Perform case/diac expansion on the exp as appropriate and
@@ -211,14 +211,14 @@ bool Db::termMatch(int typ_sens, const string &lang, const string &_term,
if (diac_sensitive) {
// Expand for diacritics and case, filtering for same diacritics
SynTermTransUnac foldtrans(UNACOP_FOLD);
synac.synKeyExpand(matcher.getptr(), exp, &foldtrans);
synac.synKeyExpand(matcher.get(), exp, &foldtrans);
} else if (case_sensitive) {
// Expand for diacritics and case, filtering for same case
SynTermTransUnac unactrans(UNACOP_UNAC);
synac.synKeyExpand(matcher.getptr(), exp, &unactrans);
synac.synKeyExpand(matcher.get(), exp, &unactrans);
} else {
// Expand for diacritics and case, no filtering
synac.synKeyExpand(matcher.getptr(), exp);
synac.synKeyExpand(matcher.get(), exp);
}
// Retrieve additional info and filter against the index itself
for (vector<string>::const_iterator it = exp.begin();
@@ -337,21 +337,21 @@ bool Db::idxTermMatch(int typ_sens, const string &lang, const string &root,
}
res.prefix = prefix;
RefCntr<StrMatcher> matcher;
STD_SHARED_PTR<StrMatcher> matcher;
if (typ == ET_REGEXP) {
matcher = RefCntr<StrMatcher>(new StrRegexpMatcher(root));
matcher = STD_SHARED_PTR<StrMatcher>(new StrRegexpMatcher(root));
if (!matcher->ok()) {
LOGERR(("termMatch: regcomp failed: %s\n",
matcher->getreason().c_str()))
return false;
}
} else if (typ == ET_WILD) {
matcher = RefCntr<StrMatcher>(new StrWildMatcher(root));
matcher = STD_SHARED_PTR<StrMatcher>(new StrWildMatcher(root));
}
// Find the initial section before any special char
string::size_type es = string::npos;
if (matcher.isNotNull()) {
if (matcher) {
es = matcher->baseprefixlen();
}
@@ -391,7 +391,7 @@ bool Db::idxTermMatch(int typ_sens, const string &lang, const string &root,
term = *it;
}
if (matcher.isNotNull() && !matcher->match(term))
if (matcher && !matcher->match(term))
continue;
res.entries.push_back(
+2 -2
View File
@@ -162,7 +162,7 @@ bool SearchData::maybeAddAutoPhrase(Rcl::Db& db, double freqThreshold)
// an actual user-entered phrase
slack += 1 + nwords / 3;
m_autophrase = RefCntr<SearchDataClauseDist>(
m_autophrase = STD_SHARED_PTR<SearchDataClauseDist>(
new SearchDataClauseDist(SCLT_PHRASE, swords, slack, field));
return true;
}
@@ -341,7 +341,7 @@ void SearchDataClauseDist::dump(ostream& o) const
void SearchDataClauseSub::dump(ostream& o) const
{
o << "ClauseSub {\n";
m_sub.getconstptr()->dump(o);
m_sub->dump(o);
o << "}";
}
+6 -6
View File
@@ -29,7 +29,7 @@
#include <ostream>
#include "rcldb.h"
#include "refcntr.h"
#include MEMORY_INCLUDE
#include "smallut.h"
#include "cstr.h"
#include "hldata.h"
@@ -174,7 +174,7 @@ private:
std::vector<std::string> m_nfiletypes;
// Autophrase if set. Can't be part of the normal chain because
// it uses OP_AND_MAYBE
RefCntr<SearchDataClauseDist> m_autophrase;
STD_SHARED_PTR<SearchDataClauseDist> m_autophrase;
// Special stuff produced by input which looks like a clause but means
// something else (date and size specs)
@@ -487,7 +487,7 @@ private:
/** Subquery */
class SearchDataClauseSub : public SearchDataClause {
public:
SearchDataClauseSub(RefCntr<SearchData> sub)
SearchDataClauseSub(STD_SHARED_PTR<SearchData> sub)
: SearchDataClause(SCLT_SUB), m_sub(sub)
{
}
@@ -501,15 +501,15 @@ public:
virtual void getTerms(HighlightData& hldata) const
{
m_sub.getconstptr()->getTerms(hldata);
m_sub.get()->getTerms(hldata);
}
virtual RefCntr<SearchData> getSub() {
virtual STD_SHARED_PTR<SearchData> getSub() {
return m_sub;
}
virtual void dump(ostream& o) const;
protected:
RefCntr<SearchData> m_sub;
STD_SHARED_PTR<SearchData> m_sub;
};
} // Namespace Rcl
+1 -1
View File
@@ -250,7 +250,7 @@ bool SearchData::toNativeQuery(Rcl::Db &db, void *d)
}
// Add the autophrase if any
if (m_autophrase.isNotNull()) {
if (m_autophrase) {
Xapian::Query apq;
if (m_autophrase->toNativeQuery(db, &apq)) {
xq = xq.empty() ? apq :
+5 -5
View File
@@ -20,13 +20,13 @@
#include <iostream>
#include <algorithm>
#include MEMORY_INCLUDE
#include "debuglog.h"
#include "cstr.h"
#include "xmacros.h"
#include "synfamily.h"
#include "smallut.h"
#include "refcntr.h"
using namespace std;
@@ -188,9 +188,9 @@ bool XapComputableSynFamMember::synKeyExpand(StrMatcher* inexp,
LOGDEB(("XapCompSynFam::synKeyExpand: [%s]\n", inexp->exp().c_str()));
// If set, compute filtering term (e.g.: only case-folded)
RefCntr<StrMatcher> filter_exp;
STD_SHARED_PTR<StrMatcher> filter_exp;
if (filtertrans) {
filter_exp = RefCntr<StrMatcher>(inexp->clone());
filter_exp = STD_SHARED_PTR<StrMatcher>(inexp->clone());
filter_exp->setExp((*filtertrans)(inexp->exp()));
}
@@ -217,7 +217,7 @@ bool XapComputableSynFamMember::synKeyExpand(StrMatcher* inexp,
m_family.getdb().synonyms_begin(*xit);
xit1 != m_family.getdb().synonyms_end(*xit); xit1++) {
string term = *xit1;
if (filter_exp.isNotNull()) {
if (filter_exp) {
string term1 = (*filtertrans)(term);
LOGDEB2((" Testing [%s] against [%s]\n",
term1.c_str(), filter_exp->exp().c_str()));
@@ -231,7 +231,7 @@ bool XapComputableSynFamMember::synKeyExpand(StrMatcher* inexp,
}
// Same with key itself
string term = (*xit).substr(preflen);
if (filter_exp.isNotNull()) {
if (filter_exp) {
string term1 = (*filtertrans)(term);
LOGDEB2((" Testing [%s] against [%s]\n",
term1.c_str(), filter_exp->exp().c_str()));