suppressed a few wasteful string-cstr conversions

This commit is contained in:
dockes
2008-07-01 11:51:51 +00:00
parent 0460f1016c
commit 022e0e5f43
14 changed files with 78 additions and 71 deletions
+9 -9
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.133 2008-06-13 18:22:46 dockes Exp $ (C) 2004 J.F.Dockes";
static char rcsid[] = "@(#$Id: rcldb.cpp,v 1.134 2008-07-01 11:51:51 dockes Exp $ (C) 2004 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -122,7 +122,7 @@ bool Db::Native::subDocs(const string &hash, vector<Xapian::docid>& docids)
if (ermsg.empty())
ermsg = "Empty error message";
} catch (const char *s) {
ermsg = s ? s : "";
ermsg = s ? s : string();
if (ermsg.empty())
ermsg = "Empty error message";
} catch (...) {
@@ -202,7 +202,7 @@ string Db::Native::makeAbstract(Xapian::docid docid, Query *query)
list<string> terms = noPrefixList(iterms);
if (terms.empty()) {
return "";
return string();
}
// Retrieve db-wide frequencies for the query terms
@@ -289,7 +289,7 @@ string Db::Native::makeAbstract(Xapian::docid docid, Query *query)
// This can't happen, but would crash us
if (totalweight == 0.0) {
LOGERR(("makeAbstract: 0 totalweight!\n"));
return "";
return string();
}
// Let's go populate
@@ -348,7 +348,7 @@ string Db::Native::makeAbstract(Xapian::docid docid, Query *query)
// This can happen if there are term occurences in the keywords
// etc. but not elsewhere ?
if (qtermposs.size() == 0)
return "";
return string();
// Walk all document's terms position lists and populate slots
// around the query terms. We arbitrarily truncate the list to
@@ -593,7 +593,7 @@ bool Db::reOpen()
if (m_ndb && m_ndb->m_isopen) {
if (!close())
return false;
if (!open(m_basedir, "", m_mode, true)) {
if (!open(m_basedir, string(), m_mode, true)) {
return false;
}
}
@@ -684,7 +684,7 @@ bool Db::fieldToPrefix(const string& fldname, string &pfx)
// This is the default table
static map<string, string> fldToPrefs;
if (fldToPrefs.empty()) {
fldToPrefs["abstract"] = "";
fldToPrefs["abstract"] = string();
fldToPrefs["ext"] = "XE";
fldToPrefs["title"] = "S";
@@ -778,14 +778,14 @@ bool mySplitterCB::takeword(const std::string &term, int pos, int, int)
// want to stop indexation because of a bad string
bool dumb_string(const string &in, string &out)
{
out.erase();
out.clear();
if (in.empty())
return true;
string s1 = neutchars(in, "\n\r");
if (!unacmaybefold(s1, out, "UTF-8", true)) {
LOGINFO(("dumb_string: unac failed for [%s]\n", in.c_str()));
out.erase();
out.clear();
// See comment at start of func
return true;
}
+2 -2
View File
@@ -1,5 +1,5 @@
#ifndef lint
static char rcsid[] = "@(#$Id: rclquery.cpp,v 1.2 2008-07-01 08:31:08 dockes Exp $ (C) 2008 J.F.Dockes";
static char rcsid[] = "@(#$Id: rclquery.cpp,v 1.3 2008-07-01 11:51:51 dockes Exp $ (C) 2008 J.F.Dockes";
#endif
#include <list>
@@ -101,7 +101,7 @@ bool Query::setQuery(RefCntr<SearchData> sdata, int opts,
}
Xapian::Query xq;
if (!sdata->toNativeQuery(*m_db, &xq, (opts & QO_STEM) ? stemlang : "")) {
if (!sdata->toNativeQuery(*m_db, &xq, (opts & QO_STEM) ? stemlang : string())) {
m_reason += sdata->getReason();
return false;
}
+3 -3
View File
@@ -16,7 +16,7 @@
*/
#ifndef _SEARCHDATA_H_INCLUDED_
#define _SEARCHDATA_H_INCLUDED_
/* @(#$Id: searchdata.h,v 1.14 2008-06-13 18:22:46 dockes Exp $ (C) 2004 J.F.Dockes */
/* @(#$Id: searchdata.h,v 1.15 2008-07-01 11:51:51 dockes Exp $ (C) 2004 J.F.Dockes */
/**
* Structures to hold data coming almost directly from the gui
@@ -160,7 +160,7 @@ protected:
class SearchDataClauseSimple : public SearchDataClause {
public:
SearchDataClauseSimple(SClType tp, const string& txt,
const string& fld = "")
const string& fld = string())
: SearchDataClause(tp), m_text(txt), m_field(fld), m_slack(0) {
m_haveWildCards = (txt.find_first_of("*?[") != string::npos);
}
@@ -212,7 +212,7 @@ public:
class SearchDataClauseDist : public SearchDataClauseSimple {
public:
SearchDataClauseDist(SClType tp, const string& txt, int slack,
const string& fld = "")
const string& fld = string())
: SearchDataClauseSimple(tp, txt, fld) {m_slack = slack;}
virtual ~SearchDataClauseDist() {}