summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTad Marshall <tad@10gen.com>2012-08-02 05:55:24 -0400
committerTad Marshall <tad@10gen.com>2012-08-31 11:44:37 -0400
commit15624a7a7e60ce1f50fc50f6cba54398b2af17d2 (patch)
treea6f830ee48e31ad7a0a69bd13fe97fa42c16b94e /src
parent1f8725142aee6cd4598ff360f638055e44557bec (diff)
downloadmongo-15624a7a7e60ce1f50fc50f6cba54398b2af17d2.tar.gz
SERVER-6908 Don't pass strings by value
Change lots of code to take <string> arguments by const ref instead of by value; minor changes to surrounding code.
Diffstat (limited to 'src')
-rw-r--r--src/mongo/bson/bson-inl.h4
-rw-r--r--src/mongo/bson/bson.h4
-rw-r--r--src/mongo/bson/oid.cpp2
-rw-r--r--src/mongo/bson/oid.h2
-rw-r--r--src/mongo/client/connpool.h2
-rw-r--r--src/mongo/client/distlock.cpp9
-rw-r--r--src/mongo/client/distlock.h2
-rw-r--r--src/mongo/client/syncclusterconnection.cpp16
-rw-r--r--src/mongo/client/syncclusterconnection.h7
-rw-r--r--src/mongo/db/client.cpp8
-rw-r--r--src/mongo/db/client.h8
-rw-r--r--src/mongo/db/commands/group.cpp16
-rw-r--r--src/mongo/db/commands/mr.cpp2
-rw-r--r--src/mongo/db/commands/mr.h2
-rw-r--r--src/mongo/db/dbwebserver.cpp8
-rw-r--r--src/mongo/db/dbwebserver.h2
-rw-r--r--src/mongo/db/dur.cpp2
-rw-r--r--src/mongo/db/dur.h6
-rw-r--r--src/mongo/db/durop.cpp2
-rw-r--r--src/mongo/db/durop.h4
-rw-r--r--src/mongo/db/extsort.cpp2
-rw-r--r--src/mongo/db/extsort.h4
-rw-r--r--src/mongo/db/geo/core.h2
-rw-r--r--src/mongo/db/helpers/dblogger.h2
-rw-r--r--src/mongo/db/index_update.cpp2
-rw-r--r--src/mongo/db/index_update.h6
-rw-r--r--src/mongo/db/memconcept.cpp2
-rw-r--r--src/mongo/db/mongommf.cpp6
-rw-r--r--src/mongo/db/mongommf.h6
-rw-r--r--src/mongo/db/oplogreader.h2
-rw-r--r--src/mongo/db/pdfile.cpp2
-rw-r--r--src/mongo/db/pdfile.h2
-rwxr-xr-xsrc/mongo/db/pipeline/accumulator.cpp13
-rwxr-xr-xsrc/mongo/db/pipeline/accumulator.h4
-rwxr-xr-xsrc/mongo/db/pipeline/builder.cpp6
-rwxr-xr-xsrc/mongo/db/pipeline/builder.h8
-rwxr-xr-xsrc/mongo/db/pipeline/document_source.h2
-rwxr-xr-xsrc/mongo/db/pipeline/document_source_group.cpp2
-rw-r--r--src/mongo/db/pipeline/expression.cpp12
-rwxr-xr-xsrc/mongo/db/pipeline/expression.h14
-rw-r--r--src/mongo/db/pipeline/value.cpp2
-rwxr-xr-xsrc/mongo/db/pipeline/value.h2
-rw-r--r--src/mongo/db/queryoptimizer.cpp4
-rw-r--r--src/mongo/db/queryoptimizer.h4
-rw-r--r--src/mongo/db/repl.cpp4
-rw-r--r--src/mongo/db/repl.h2
-rw-r--r--src/mongo/db/repl/connections.h4
-rw-r--r--src/mongo/db/repl/health.h8
-rw-r--r--src/mongo/db/repl/heartbeat.cpp9
-rw-r--r--src/mongo/db/repl/replset_commands.cpp2
-rw-r--r--src/mongo/db/repl/rs.cpp7
-rw-r--r--src/mongo/db/repl/rs.h9
-rw-r--r--src/mongo/db/repl/rs_config.h2
-rw-r--r--src/mongo/db/repl/rs_initialsync.cpp2
-rw-r--r--src/mongo/db/restapi.cpp14
-rw-r--r--src/mongo/s/config.cpp6
-rw-r--r--src/mongo/s/config.h6
-rw-r--r--src/mongo/s/d_migrate.cpp4
-rw-r--r--src/mongo/s/grid.cpp4
-rw-r--r--src/mongo/s/grid.h4
-rw-r--r--src/mongo/scripting/engine.cpp2
-rw-r--r--src/mongo/scripting/engine_spidermonkey.cpp8
-rw-r--r--src/mongo/shell/dbshell.cpp11
-rw-r--r--src/mongo/util/assert_util.cpp2
-rw-r--r--src/mongo/util/assert_util.h4
-rw-r--r--src/mongo/util/concurrency/msg.h2
-rw-r--r--src/mongo/util/concurrency/race.h2
-rw-r--r--src/mongo/util/goodies.h4
-rw-r--r--src/mongo/util/log.h2
-rw-r--r--src/mongo/util/logfile.cpp4
-rw-r--r--src/mongo/util/logfile.h2
-rw-r--r--src/mongo/util/md5.hpp2
-rw-r--r--src/mongo/util/mmap.cpp4
-rw-r--r--src/mongo/util/mmap.h6
-rw-r--r--src/mongo/util/mmap_win.cpp5
-rw-r--r--src/mongo/util/mongoutils/html.h26
-rw-r--r--src/mongo/util/mongoutils/str.h50
-rw-r--r--src/mongo/util/net/hostandport.h6
-rw-r--r--src/mongo/util/net/httpclient.cpp4
-rw-r--r--src/mongo/util/net/httpclient.h4
-rw-r--r--src/mongo/util/net/listen.h2
-rw-r--r--src/mongo/util/net/miniwebserver.cpp2
-rw-r--r--src/mongo/util/net/miniwebserver.h4
-rw-r--r--src/mongo/util/net/sock.h2
-rw-r--r--src/mongo/util/ntservice.cpp4
-rw-r--r--src/mongo/util/ntservice.h4
-rw-r--r--src/mongo/util/paths.h2
-rw-r--r--src/mongo/util/progress_meter.h2
-rw-r--r--src/mongo/util/ramlog.cpp8
-rw-r--r--src/mongo/util/ramlog.h6
-rw-r--r--src/mongo/util/text.cpp2
-rw-r--r--src/mongo/util/text.h2
92 files changed, 274 insertions, 222 deletions
diff --git a/src/mongo/bson/bson-inl.h b/src/mongo/bson/bson-inl.h
index c6634b1e14c..cbe547bb6cf 100644
--- a/src/mongo/bson/bson-inl.h
+++ b/src/mongo/bson/bson-inl.h
@@ -916,9 +916,9 @@ dodouble:
}
// used by jsonString()
- inline std::string escape( std::string s , bool escape_slash=false) {
+ inline std::string escape( const std::string& s , bool escape_slash=false) {
StringBuilder ret;
- for ( std::string::iterator i = s.begin(); i != s.end(); ++i ) {
+ for ( std::string::const_iterator i = s.begin(); i != s.end(); ++i ) {
switch ( *i ) {
case '"':
ret << "\\\"";
diff --git a/src/mongo/bson/bson.h b/src/mongo/bson/bson.h
index a26ba09f784..2c8d61bd3da 100644
--- a/src/mongo/bson/bson.h
+++ b/src/mongo/bson/bson.h
@@ -84,7 +84,7 @@ namespace mongo {
throw bson::assertion( msgid , s );
}
- inline void uassert(unsigned msgid, std::string msg, bool expr) {
+ inline void uassert(unsigned msgid, const std::string& msg, bool expr) {
if( !expr )
uasserted( msgid , msg );
}
@@ -94,7 +94,7 @@ namespace mongo {
MONGO_COMPILER_NORETURN inline void msgasserted(int msgid, const std::string &msg) {
msgasserted(msgid, msg.c_str());
}
- inline void massert(int msgid, std::string msg, bool expr) {
+ inline void massert(int msgid, const std::string& msg, bool expr) {
if(!expr) {
std::cout << "assertion failure in bson library: " << msgid << ' ' << msg << std::endl;
throw bson::assertion( msgid , msg );
diff --git a/src/mongo/bson/oid.cpp b/src/mongo/bson/oid.cpp
index 15bc15f6502..ef82e525422 100644
--- a/src/mongo/bson/oid.cpp
+++ b/src/mongo/bson/oid.cpp
@@ -157,7 +157,7 @@ namespace mongo {
}
}
- void OID::init( string s ) {
+ void OID::init( const std::string& s ) {
verify( s.size() == 24 );
const char *p = s.c_str();
for( int i = 0; i < 12; i++ ) {
diff --git a/src/mongo/bson/oid.h b/src/mongo/bson/oid.h
index 62732a67ab4..36db5380e55 100644
--- a/src/mongo/bson/oid.h
+++ b/src/mongo/bson/oid.h
@@ -79,7 +79,7 @@ namespace mongo {
void initSequential();
/** init from a 24 char hex string */
- void init( std::string s );
+ void init( const std::string& s );
/** Set to the min/max OID that could be generated at given timestamp. */
void init( Date_t date, bool max=false );
diff --git a/src/mongo/client/connpool.h b/src/mongo/client/connpool.h
index 4e8e8dcd35f..b785e9d04f6 100644
--- a/src/mongo/client/connpool.h
+++ b/src/mongo/client/connpool.h
@@ -152,7 +152,7 @@ namespace mongo {
DBClientBase* _finishCreate( const string& ident , double socketTimeout, DBClientBase* conn );
struct PoolKey {
- PoolKey( string i , double t ) : ident( i ) , timeout( t ) {}
+ PoolKey( const std::string& i , double t ) : ident( i ) , timeout( t ) {}
string ident;
double timeout;
};
diff --git a/src/mongo/client/distlock.cpp b/src/mongo/client/distlock.cpp
index 7345a692168..5413cbc6e10 100644
--- a/src/mongo/client/distlock.cpp
+++ b/src/mongo/client/distlock.cpp
@@ -79,7 +79,9 @@ namespace mongo {
: _mutex( "DistributedLockPinger" ) {
}
- void _distLockPingThread( ConnectionString addr, string process, unsigned long long sleepTime ) {
+ void _distLockPingThread( ConnectionString addr,
+ const std::string& process,
+ unsigned long long sleepTime ) {
setThreadName( "LockPinger" );
@@ -216,7 +218,10 @@ namespace mongo {
}
- void distLockPingThread( ConnectionString addr, long long clockSkew, string processId, unsigned long long sleepTime ) {
+ void distLockPingThread( ConnectionString addr,
+ long long clockSkew,
+ const std::string& processId,
+ unsigned long long sleepTime ) {
try {
jsTimeVirtualThreadSkew( clockSkew );
_distLockPingThread( addr, processId, sleepTime );
diff --git a/src/mongo/client/distlock.h b/src/mongo/client/distlock.h
index 70aa3bd158c..92df434df1a 100644
--- a/src/mongo/client/distlock.h
+++ b/src/mongo/client/distlock.h
@@ -218,7 +218,7 @@ namespace mongo {
return *this;
}
- dist_lock_try( DistributedLock * lock , string why )
+ dist_lock_try( DistributedLock * lock , const std::string& why )
: _lock(lock), _why(why) {
_got = _lock->lock_try( why , false , &_other );
}
diff --git a/src/mongo/client/syncclusterconnection.cpp b/src/mongo/client/syncclusterconnection.cpp
index d09c4be3d02..0b5e1150e3b 100644
--- a/src/mongo/client/syncclusterconnection.cpp
+++ b/src/mongo/client/syncclusterconnection.cpp
@@ -42,19 +42,19 @@ namespace mongo {
_connect( i->toString() );
}
- SyncClusterConnection::SyncClusterConnection( string commaSeperated, double socketTimeout) : _mutex("SyncClusterConnection"), _socketTimeout( socketTimeout ) {
- _address = commaSeperated;
+ SyncClusterConnection::SyncClusterConnection( string commaSeparated, double socketTimeout) : _mutex("SyncClusterConnection"), _socketTimeout( socketTimeout ) {
+ _address = commaSeparated;
string::size_type idx;
- while ( ( idx = commaSeperated.find( ',' ) ) != string::npos ) {
- string h = commaSeperated.substr( 0 , idx );
- commaSeperated = commaSeperated.substr( idx + 1 );
+ while ( ( idx = commaSeparated.find( ',' ) ) != string::npos ) {
+ string h = commaSeparated.substr( 0 , idx );
+ commaSeparated = commaSeparated.substr( idx + 1 );
_connect( h );
}
- _connect( commaSeperated );
+ _connect( commaSeparated );
uassert( 8004 , "SyncClusterConnection needs 3 servers" , _conns.size() == 3 );
}
- SyncClusterConnection::SyncClusterConnection( string a , string b , string c, double socketTimeout) : _mutex("SyncClusterConnection"), _socketTimeout( socketTimeout ) {
+ SyncClusterConnection::SyncClusterConnection( const std::string& a , const std::string& b , const std::string& c, double socketTimeout) : _mutex("SyncClusterConnection"), _socketTimeout( socketTimeout ) {
_address = a + "," + b + "," + c;
// connect to all even if not working
_connect( a );
@@ -146,7 +146,7 @@ namespace mongo {
return DBClientBase::getLastErrorDetailed(fsync,j,w,wtimeout);
}
- void SyncClusterConnection::_connect( string host ) {
+ void SyncClusterConnection::_connect( const std::string& host ) {
log() << "SyncClusterConnection connecting to [" << host << "]" << endl;
DBClientConnection * c = new DBClientConnection( true );
c->setSoTimeout( _socketTimeout );
diff --git a/src/mongo/client/syncclusterconnection.h b/src/mongo/client/syncclusterconnection.h
index 3907f7e50a0..02cc864bed4 100644
--- a/src/mongo/client/syncclusterconnection.h
+++ b/src/mongo/client/syncclusterconnection.h
@@ -51,7 +51,10 @@ namespace mongo {
*/
SyncClusterConnection( const list<HostAndPort> &, double socketTimeout = 0);
SyncClusterConnection( string commaSeparated, double socketTimeout = 0);
- SyncClusterConnection( string a , string b , string c, double socketTimeout = 0 );
+ SyncClusterConnection( const std::string& a,
+ const std::string& b,
+ const std::string& c,
+ double socketTimeout = 0 );
~SyncClusterConnection();
/**
@@ -114,7 +117,7 @@ namespace mongo {
const BSONObj *fieldsToReturn, int queryOptions, int batchSize );
int _lockType( const string& name );
void _checkLast();
- void _connect( string host );
+ void _connect( const std::string& host );
string _address;
vector<string> _connAddresses;
diff --git a/src/mongo/db/client.cpp b/src/mongo/db/client.cpp
index 11216632fa1..a1527802e37 100644
--- a/src/mongo/db/client.cpp
+++ b/src/mongo/db/client.cpp
@@ -186,7 +186,7 @@ namespace mongo {
}
BSONObj CachedBSONObj::_tooBig = fromjson("{\"$msg\":\"query not recording (too large)\"}");
- Client::Context::Context( string ns , Database * db, bool doauth ) :
+ Client::Context::Context( const std::string& ns , Database * db, bool doauth ) :
_client( currentClient.get() ),
_oldContext( _client->_context ),
_path( mongo::dbpath ), // is this right? could be a different db? may need a dassert for this
@@ -200,7 +200,7 @@ namespace mongo {
checkNsAccess( doauth );
}
- Client::Context::Context(const string& ns, string path , bool doauth, bool doVersion ) :
+ Client::Context::Context(const string& ns, const std::string& path , bool doauth, bool doVersion ) :
_client( currentClient.get() ),
_oldContext( _client->_context ),
_path( path ),
@@ -215,7 +215,7 @@ namespace mongo {
/** "read lock, and set my context, all in one operation"
* This handles (if not recursively locked) opening an unopened database.
*/
- Client::ReadContext::ReadContext(const string& ns, string path, bool doauth ) {
+ Client::ReadContext::ReadContext(const string& ns, const std::string& path, bool doauth ) {
{
lk.reset( new Lock::DBRead(ns) );
Database *db = dbHolder().get(ns, path);
@@ -253,7 +253,7 @@ namespace mongo {
// it would be easy to first check that there is at least a .ns file, or something similar.
}
- Client::WriteContext::WriteContext(const string& ns, string path , bool doauth )
+ Client::WriteContext::WriteContext(const string& ns, const std::string& path , bool doauth )
: _lk( ns ) ,
_c( ns , path , doauth ) {
}
diff --git a/src/mongo/db/client.h b/src/mongo/db/client.h
index c2142115ca5..717d2344f26 100644
--- a/src/mongo/db/client.h
+++ b/src/mongo/db/client.h
@@ -168,7 +168,7 @@ namespace mongo {
*/
class ReadContext : boost::noncopyable {
public:
- ReadContext(const string& ns, string path=dbpath, bool doauth=true );
+ ReadContext(const std::string& ns, const std::string& path=dbpath, bool doauth=true );
Context& ctx() { return *c.get(); }
private:
scoped_ptr<Lock::DBRead> lk;
@@ -181,13 +181,13 @@ namespace mongo {
class Context : boost::noncopyable {
public:
/** this is probably what you want */
- Context(const string& ns, string path=dbpath, bool doauth=true, bool doVersion=true );
+ Context(const string& ns, const std::string& path=dbpath, bool doauth=true, bool doVersion=true );
/** note: this does not call finishInit -- i.e., does not call
shardVersionOk() for example.
see also: reset().
*/
- Context( string ns , Database * db, bool doauth=true );
+ Context( const std::string& ns , Database * db, bool doauth=true );
// used by ReadContext
Context(const string& path, const string& ns, Database *db, bool doauth);
@@ -237,7 +237,7 @@ namespace mongo {
class WriteContext : boost::noncopyable {
public:
- WriteContext(const string& ns, string path=dbpath, bool doauth=true );
+ WriteContext(const string& ns, const std::string& path=dbpath, bool doauth=true );
Context& ctx() { return _c; }
private:
Lock::DBWrite _lk;
diff --git a/src/mongo/db/commands/group.cpp b/src/mongo/db/commands/group.cpp
index 9fbd56d8a4b..61adfc9efc7 100644
--- a/src/mongo/db/commands/group.cpp
+++ b/src/mongo/db/commands/group.cpp
@@ -47,11 +47,17 @@ namespace mongo {
return obj.extractFields( keyPattern , true ).getOwned();
}
- bool group( string realdbname , const string& ns , const BSONObj& query ,
- BSONObj keyPattern , string keyFunctionCode , string reduceCode , const char * reduceScope ,
- BSONObj initial , string finalize ,
- string& errmsg , BSONObjBuilder& result ) {
-
+ bool group( const std::string& realdbname,
+ const std::string& ns,
+ const BSONObj& query,
+ BSONObj keyPattern,
+ const std::string& keyFunctionCode,
+ const std::string& reduceCode,
+ const char * reduceScope,
+ BSONObj initial,
+ const std::string& finalize,
+ string& errmsg,
+ BSONObjBuilder& result ) {
auto_ptr<Scope> s = globalScriptEngine->getPooledScope( realdbname );
s->localConnect( realdbname.c_str() );
diff --git a/src/mongo/db/commands/mr.cpp b/src/mongo/db/commands/mr.cpp
index de2113d0fc0..7f69a847398 100644
--- a/src/mongo/db/commands/mr.cpp
+++ b/src/mongo/db/commands/mr.cpp
@@ -37,7 +37,7 @@ namespace mongo {
AtomicUInt Config::JOB_NUMBER;
- JSFunction::JSFunction( string type , const BSONElement& e ) {
+ JSFunction::JSFunction( const std::string& type , const BSONElement& e ) {
_type = type;
_code = e._asCode();
diff --git a/src/mongo/db/commands/mr.h b/src/mongo/db/commands/mr.h
index e547f475dc7..76ef7091ff9 100644
--- a/src/mongo/db/commands/mr.h
+++ b/src/mongo/db/commands/mr.h
@@ -72,7 +72,7 @@ namespace mongo {
/**
* @param type (map|reduce|finalize)
*/
- JSFunction( string type , const BSONElement& e );
+ JSFunction( const std::string& type , const BSONElement& e );
virtual ~JSFunction() {}
virtual void init( State * state );
diff --git a/src/mongo/db/dbwebserver.cpp b/src/mongo/db/dbwebserver.cpp
index f427d24cf80..67d7746b18f 100644
--- a/src/mongo/db/dbwebserver.cpp
+++ b/src/mongo/db/dbwebserver.cpp
@@ -373,7 +373,7 @@ namespace mongo {
public:
FavIconHandler() : DbWebHandler( "favicon.ico" , 0 , false ) {}
- virtual void handle( const char *rq, string url, BSONObj params,
+ virtual void handle( const char *rq, const std::string& url, BSONObj params,
string& responseMsg, int& responseCode,
vector<string>& headers, const SockAddr &from ) {
responseCode = 404;
@@ -387,7 +387,7 @@ namespace mongo {
public:
StatusHandler() : DbWebHandler( "_status" , 1 , false ) {}
- virtual void handle( const char *rq, string url, BSONObj params,
+ virtual void handle( const char *rq, const std::string& url, BSONObj params,
string& responseMsg, int& responseCode,
vector<string>& headers, const SockAddr &from ) {
headers.push_back( "Content-Type: application/json;charset=utf-8" );
@@ -439,7 +439,7 @@ namespace mongo {
public:
CommandListHandler() : DbWebHandler( "_commands" , 1 , true ) {}
- virtual void handle( const char *rq, string url, BSONObj params,
+ virtual void handle( const char *rq, const std::string& url, BSONObj params,
string& responseMsg, int& responseCode,
vector<string>& headers, const SockAddr &from ) {
headers.push_back( "Content-Type: text/html;charset=utf-8" );
@@ -491,7 +491,7 @@ namespace mongo {
return _cmd(cmd) != 0;
}
- virtual void handle( const char *rq, string url, BSONObj params,
+ virtual void handle( const char *rq, const std::string& url, BSONObj params,
string& responseMsg, int& responseCode,
vector<string>& headers, const SockAddr &from ) {
string cmd;
diff --git a/src/mongo/db/dbwebserver.h b/src/mongo/db/dbwebserver.h
index bdbcba2c07d..04715963249 100644
--- a/src/mongo/db/dbwebserver.h
+++ b/src/mongo/db/dbwebserver.h
@@ -39,7 +39,7 @@ namespace mongo {
virtual bool requiresREST( const string& url ) const { return _requiresREST; }
virtual void handle( const char *rq, // the full request
- string url,
+ const std::string& url,
BSONObj params,
// set these and return them:
string& responseMsg,
diff --git a/src/mongo/db/dur.cpp b/src/mongo/db/dur.cpp
index 978c4bea9eb..b83957bfc32 100644
--- a/src/mongo/db/dur.cpp
+++ b/src/mongo/db/dur.cpp
@@ -217,7 +217,7 @@ namespace mongo {
is created first, and the journal will just replay the creation if the create didn't
happen because of crashing.
*/
- void DurableImpl::createdFile(string filename, unsigned long long len) {
+ void DurableImpl::createdFile(const std::string& filename, unsigned long long len) {
shared_ptr<DurOp> op( new FileCreatedOp(filename, len) );
commitJob.noteOp(op);
}
diff --git a/src/mongo/db/dur.h b/src/mongo/db/dur.h
index ffacf90f591..9914264c83e 100644
--- a/src/mongo/db/dur.h
+++ b/src/mongo/db/dur.h
@@ -34,7 +34,7 @@ namespace mongo {
is created first, and the journal will just replay the creation if the create didn't
happen because of crashing.
*/
- virtual void createdFile(string filename, unsigned long long len) = 0;
+ virtual void createdFile(const std::string& filename, unsigned long long len) = 0;
/** Declarations of write intent.
@@ -168,7 +168,7 @@ namespace mongo {
void* writingAtOffset(void *buf, unsigned ofs, unsigned len) { return buf; }
void* writingRangesAtOffsets(void *buf, const vector< pair< long long, unsigned > > &ranges) { return buf; }
void declareWriteIntent(void *, unsigned);
- void createdFile(string filename, unsigned long long len) { }
+ void createdFile(const std::string& filename, unsigned long long len) { }
bool awaitCommit() { return false; }
bool commitNow() { return false; }
bool commitIfNeeded(bool) { return false; }
@@ -182,7 +182,7 @@ namespace mongo {
void* writingAtOffset(void *buf, unsigned ofs, unsigned len);
void* writingRangesAtOffsets(void *buf, const vector< pair< long long, unsigned > > &ranges);
void declareWriteIntent(void *, unsigned);
- void createdFile(string filename, unsigned long long len);
+ void createdFile(const std::string& filename, unsigned long long len);
bool awaitCommit();
bool commitNow();
bool aCommitIsNeeded() const;
diff --git a/src/mongo/db/durop.cpp b/src/mongo/db/durop.cpp
index dae10f0cbbc..b0039c93b74 100644
--- a/src/mongo/db/durop.cpp
+++ b/src/mongo/db/durop.cpp
@@ -82,7 +82,7 @@ namespace mongo {
_deleteDataFiles(_db.c_str());
}
- FileCreatedOp::FileCreatedOp(string f, unsigned long long l) :
+ FileCreatedOp::FileCreatedOp(const std::string& f, unsigned long long l) :
DurOp(JEntry::OpCode_FileCreated) {
_p = RelativePath::fromFullPath(f);
_len = l;
diff --git a/src/mongo/db/durop.h b/src/mongo/db/durop.h
index 9ab1bfcbede..77b2a8a34f8 100644
--- a/src/mongo/db/durop.h
+++ b/src/mongo/db/durop.h
@@ -78,7 +78,7 @@ namespace mongo {
public:
FileCreatedOp(BufReader& log);
/** param f filename to create with path */
- FileCreatedOp(string f, unsigned long long l);
+ FileCreatedOp(const std::string& f, unsigned long long l);
virtual void replay();
virtual string toString();
virtual bool needFilesClosed();
@@ -93,7 +93,7 @@ namespace mongo {
class DropDbOp : public DurOp {
public:
DropDbOp(BufReader& log);
- DropDbOp(string db) :
+ DropDbOp(const std::string& db) :
DurOp(JEntry::OpCode_DropDb), _db(db) { }
virtual void replay();
virtual string toString() { return string("DropDbOp ") + _db; }
diff --git a/src/mongo/db/extsort.cpp b/src/mongo/db/extsort.cpp
index 982555ce8c1..4629873f4e6 100644
--- a/src/mongo/db/extsort.cpp
+++ b/src/mongo/db/extsort.cpp
@@ -260,7 +260,7 @@ namespace mongo {
// -----------------------------------
- BSONObjExternalSorter::FileIterator::FileIterator( string file ) {
+ BSONObjExternalSorter::FileIterator::FileIterator( const std::string& file ) {
#ifdef _WIN32
_file = ::_open( file.c_str(), _O_BINARY | _O_RDWR | _O_CREAT , _S_IREAD | _S_IWRITE );
#else
diff --git a/src/mongo/db/extsort.h b/src/mongo/db/extsort.h
index a1107fa9426..853c02283ca 100644
--- a/src/mongo/db/extsort.h
+++ b/src/mongo/db/extsort.h
@@ -62,7 +62,7 @@ namespace mongo {
class FileIterator : boost::noncopyable {
public:
- FileIterator( string file );
+ FileIterator( const std::string& file );
~FileIterator();
bool more();
Data next();
@@ -124,7 +124,7 @@ namespace mongo {
void _sortInMem();
- void sort( string file );
+ void sort( const std::string& file );
void finishMap();
BSONObj _order;
diff --git a/src/mongo/db/geo/core.h b/src/mongo/db/geo/core.h
index 32d62bdc1dd..25a2f3b9239 100644
--- a/src/mongo/db/geo/core.h
+++ b/src/mongo/db/geo/core.h
@@ -341,7 +341,7 @@ namespace mongo {
return n;
}
- GeoHash operator+( string s ) const {
+ GeoHash operator+( const std::string& s ) const {
return operator+( s.c_str() );
}
diff --git a/src/mongo/db/helpers/dblogger.h b/src/mongo/db/helpers/dblogger.h
index 4d6ee6d78c4..52d5e4db646 100644
--- a/src/mongo/db/helpers/dblogger.h
+++ b/src/mongo/db/helpers/dblogger.h
@@ -25,7 +25,7 @@ namespace mongo {
bool _inited;
public:
const string _ns;
- DBLogger(string ns) : _inited(false), _ns(ns) { }
+ DBLogger(const std::string& ns) : _inited(false), _ns(ns) { }
};
}
diff --git a/src/mongo/db/index_update.cpp b/src/mongo/db/index_update.cpp
index fcb36f3ba46..c1acd9ba0c1 100644
--- a/src/mongo/db/index_update.cpp
+++ b/src/mongo/db/index_update.cpp
@@ -479,7 +479,7 @@ namespace mongo {
};
// throws DBException
- void buildAnIndex(string ns, NamespaceDetails *d, IndexDetails& idx, int idxNo, bool background) {
+ void buildAnIndex(const std::string& ns, NamespaceDetails *d, IndexDetails& idx, int idxNo, bool background) {
tlog() << "build index " << ns << ' ' << idx.keyPattern() << ( background ? " background" : "" ) << endl;
Timer t;
unsigned long long n;
diff --git a/src/mongo/db/index_update.h b/src/mongo/db/index_update.h
index 128889e7d17..81a777d3b2b 100644
--- a/src/mongo/db/index_update.h
+++ b/src/mongo/db/index_update.h
@@ -30,7 +30,11 @@ namespace mongo {
// Build an index in the foreground
// If background is false, uses fast index builder
// If background is true, uses background index builder; blocks until done.
- void buildAnIndex(string ns, NamespaceDetails *d, IndexDetails& idx, int idxNo, bool background);
+ void buildAnIndex(const std::string& ns,
+ NamespaceDetails *d,
+ IndexDetails& idx,
+ int idxNo,
+ bool background);
// add index keys for a newly inserted record
// done in two steps/phases to allow potential deferal of write lock portion in the future
diff --git a/src/mongo/db/memconcept.cpp b/src/mongo/db/memconcept.cpp
index d41afcbf2a3..3d3ebe72032 100644
--- a/src/mongo/db/memconcept.cpp
+++ b/src/mongo/db/memconcept.cpp
@@ -86,7 +86,7 @@ namespace mongo {
#if 0 && defined(_DEBUG)
bool d = false;
- void is(void *p, concept c, string description, unsigned len) {
+ void is(void *p, concept c, const std::string& description, unsigned len) {
DDD( log() << "is " << p << ' ' << c.toString() << ' ' << description << ' ' << len << endl; )
C &node = map.find(p);
node.p = p;
diff --git a/src/mongo/db/mongommf.cpp b/src/mongo/db/mongommf.cpp
index 0ece3125291..c68dcfb61b0 100644
--- a/src/mongo/db/mongommf.cpp
+++ b/src/mongo/db/mongommf.cpp
@@ -155,7 +155,7 @@ namespace mongo {
extern string dbpath;
// here so that it is precomputed...
- void MongoMMF::setPath(string f) {
+ void MongoMMF::setPath(const std::string& f) {
string suffix;
string prefix;
bool ok = str::rSplitOn(f, '.', prefix, suffix);
@@ -168,14 +168,14 @@ namespace mongo {
_p = RelativePath::fromFullPath(prefix);
}
- bool MongoMMF::open(string fname, bool sequentialHint) {
+ bool MongoMMF::open(const std::string& fname, bool sequentialHint) {
LOG(3) << "mmf open " << fname << endl;
setPath(fname);
_view_write = mapWithOptions(fname.c_str(), sequentialHint ? SEQUENTIAL : 0);
return finishOpening();
}
- bool MongoMMF::create(string fname, unsigned long long& len, bool sequentialHint) {
+ bool MongoMMF::create(const std::string& fname, unsigned long long& len, bool sequentialHint) {
LOG(3) << "mmf create " << fname << endl;
setPath(fname);
_view_write = map(fname.c_str(), len, sequentialHint ? SEQUENTIAL : 0);
diff --git a/src/mongo/db/mongommf.h b/src/mongo/db/mongommf.h
index d3c761c32a3..3d6324443c6 100644
--- a/src/mongo/db/mongommf.h
+++ b/src/mongo/db/mongommf.h
@@ -36,7 +36,7 @@ namespace mongo {
virtual void close();
/** @return true if opened ok. */
- bool open(string fname, bool sequentialHint /*typically we open with this false*/);
+ bool open(const std::string& fname, bool sequentialHint /*typically we open with this false*/);
/** @return file length */
unsigned long long length() const { return MemoryMappedFile::length(); }
@@ -50,7 +50,7 @@ namespace mongo {
@param sequentialHint if true will be sequentially accessed
@return true for ok
*/
- bool create(string fname, unsigned long long& len, bool sequentialHint);
+ bool create(const std::string& fname, unsigned long long& len, bool sequentialHint);
/* Get the "standard" view (which is the private one).
@return the private view.
@@ -101,7 +101,7 @@ namespace mongo {
RelativePath _p; // e.g. "somepath/dbname"
int _fileSuffixNo; // e.g. 3. -1="ns"
- void setPath(string pathAndFileName);
+ void setPath(const std::string& pathAndFileName);
bool finishOpening();
};
diff --git a/src/mongo/db/oplogreader.h b/src/mongo/db/oplogreader.h
index 93c4bcdc156..8a61aeaa250 100644
--- a/src/mongo/db/oplogreader.h
+++ b/src/mongo/db/oplogreader.h
@@ -34,7 +34,7 @@ namespace mongo {
}
/* ok to call if already connected */
- bool connect(string hostname);
+ bool connect(const std::string& hostname);
bool connect(const BSONObj& rid, const int from, const string& to);
diff --git a/src/mongo/db/pdfile.cpp b/src/mongo/db/pdfile.cpp
index 64e86613296..0c424f01677 100644
--- a/src/mongo/db/pdfile.cpp
+++ b/src/mongo/db/pdfile.cpp
@@ -1625,7 +1625,7 @@ namespace mongo {
}
}
- void dropDatabase(string db) {
+ void dropDatabase(const std::string& db) {
log(1) << "dropDatabase " << db << endl;
Lock::assertWriteLocked(db);
Database *d = cc().database();
diff --git a/src/mongo/db/pdfile.h b/src/mongo/db/pdfile.h
index d1904f928b9..408640398dc 100644
--- a/src/mongo/db/pdfile.h
+++ b/src/mongo/db/pdfile.h
@@ -48,7 +48,7 @@ namespace mongo {
class Cursor;
class OpDebug;
- void dropDatabase(string db);
+ void dropDatabase(const std::string& db);
bool repairDatabase(string db, string &errmsg, bool preserveClonedFilesOnFailure = false, bool backupOriginalFiles = false);
/* low level - only drops this ns */
diff --git a/src/mongo/db/pipeline/accumulator.cpp b/src/mongo/db/pipeline/accumulator.cpp
index b100154783f..993ec126504 100755
--- a/src/mongo/db/pipeline/accumulator.cpp
+++ b/src/mongo/db/pipeline/accumulator.cpp
@@ -36,18 +36,19 @@ namespace mongo {
ExpressionNary() {
}
- void Accumulator::opToBson(
- BSONObjBuilder *pBuilder, string opName,
- string fieldName, bool requireExpression) const {
+ void Accumulator::opToBson(BSONObjBuilder *pBuilder,
+ const std::string& opName,
+ const std::string& fieldName,
+ bool requireExpression) const {
verify(vpOperand.size() == 1);
BSONObjBuilder builder;
vpOperand[0]->addToBsonObj(&builder, opName, requireExpression);
pBuilder->append(fieldName, builder.done());
}
- void Accumulator::addToBsonObj(
- BSONObjBuilder *pBuilder, string fieldName,
- bool requireExpression) const {
+ void Accumulator::addToBsonObj(BSONObjBuilder *pBuilder,
+ const std::string& fieldName,
+ bool requireExpression) const {
opToBson(pBuilder, getOpName(), fieldName, requireExpression);
}
diff --git a/src/mongo/db/pipeline/accumulator.h b/src/mongo/db/pipeline/accumulator.h
index 4ca6c94b086..1c947c9ca84 100755
--- a/src/mongo/db/pipeline/accumulator.h
+++ b/src/mongo/db/pipeline/accumulator.h
@@ -32,7 +32,7 @@ namespace mongo {
// virtuals from ExpressionNary
virtual void addOperand(const intrusive_ptr<Expression> &pExpression);
virtual void addToBsonObj(
- BSONObjBuilder *pBuilder, string fieldName,
+ BSONObjBuilder *pBuilder, const std::string& fieldName,
bool requireExpression) const;
virtual void addToBsonArray(BSONArrayBuilder *pBuilder) const;
@@ -56,7 +56,7 @@ namespace mongo {
@param opName the operator name
*/
void opToBson(
- BSONObjBuilder *pBuilder, string fieldName, string opName,
+ BSONObjBuilder *pBuilder, const std::string& fieldName, const std::string& opName,
bool requireExpression) const;
};
diff --git a/src/mongo/db/pipeline/builder.cpp b/src/mongo/db/pipeline/builder.cpp
index 8af427d8c9f..a85d75ce02f 100755
--- a/src/mongo/db/pipeline/builder.cpp
+++ b/src/mongo/db/pipeline/builder.cpp
@@ -46,7 +46,7 @@ namespace mongo {
pBuilder->append(fieldName, d);
}
- void BuilderObj::append(string s) {
+ void BuilderObj::append(const std::string& s) {
pBuilder->append(fieldName, s);
}
@@ -71,7 +71,7 @@ namespace mongo {
}
BuilderObj::BuilderObj(
- BSONObjBuilder *pObjBuilder, string theFieldName):
+ BSONObjBuilder *pObjBuilder, const std::string& theFieldName):
pBuilder(pObjBuilder),
fieldName(theFieldName) {
}
@@ -101,7 +101,7 @@ namespace mongo {
pBuilder->append(d);
}
- void BuilderArray::append(string s) {
+ void BuilderArray::append(const std::string& s) {
pBuilder->append(s);
}
diff --git a/src/mongo/db/pipeline/builder.h b/src/mongo/db/pipeline/builder.h
index 6b6a265aeea..e6a68a72a32 100755
--- a/src/mongo/db/pipeline/builder.h
+++ b/src/mongo/db/pipeline/builder.h
@@ -44,7 +44,7 @@ namespace mongo {
virtual void append(int i) = 0;
virtual void append(long long ll) = 0;
virtual void append(double d) = 0;
- virtual void append(string s) = 0;
+ virtual void append(const std::string& s) = 0;
virtual void append(const OID &o) = 0;
virtual void append(const Date_t &d) = 0;
virtual void append(const OpTime& ot) = 0;
@@ -62,14 +62,14 @@ namespace mongo {
virtual void append(int i);
virtual void append(long long ll);
virtual void append(double d);
- virtual void append(string s);
+ virtual void append(const std::string& s);
virtual void append(const OID &o);
virtual void append(const Date_t &d);
virtual void append(const OpTime& ot);
virtual void append(BSONObjBuilder *pDone);
virtual void append(BSONArrayBuilder *pDone);
- BuilderObj(BSONObjBuilder *pBuilder, string fieldName);
+ BuilderObj(BSONObjBuilder *pBuilder, const std::string& fieldName);
private:
BSONObjBuilder *pBuilder;
@@ -86,7 +86,7 @@ namespace mongo {
virtual void append(int i);
virtual void append(long long ll);
virtual void append(double d);
- virtual void append(string s);
+ virtual void append(const std::string& s);
virtual void append(const OID &o);
virtual void append(const Date_t &d);
virtual void append(const OpTime& ot);
diff --git a/src/mongo/db/pipeline/document_source.h b/src/mongo/db/pipeline/document_source.h
index 329564ac490..b5ae5c80ef5 100755
--- a/src/mongo/db/pipeline/document_source.h
+++ b/src/mongo/db/pipeline/document_source.h
@@ -625,7 +625,7 @@ namespace mongo {
@param pAccumulatorFactory used to create the accumulator for the
group field
*/
- void addAccumulator(string fieldName,
+ void addAccumulator(const std::string& fieldName,
intrusive_ptr<Accumulator> (*pAccumulatorFactory)(
const intrusive_ptr<ExpressionContext> &),
const intrusive_ptr<Expression> &pExpression);
diff --git a/src/mongo/db/pipeline/document_source_group.cpp b/src/mongo/db/pipeline/document_source_group.cpp
index 5b30b27f144..c84d73d16b6 100755
--- a/src/mongo/db/pipeline/document_source_group.cpp
+++ b/src/mongo/db/pipeline/document_source_group.cpp
@@ -119,7 +119,7 @@ namespace mongo {
}
void DocumentSourceGroup::addAccumulator(
- string fieldName,
+ const std::string& fieldName,
intrusive_ptr<Accumulator> (*pAccumulatorFactory)(
const intrusive_ptr<ExpressionContext> &),
const intrusive_ptr<Expression> &pExpression) {
diff --git a/src/mongo/db/pipeline/expression.cpp b/src/mongo/db/pipeline/expression.cpp
index 6cc54bdca21..912c251bc76 100644
--- a/src/mongo/db/pipeline/expression.cpp
+++ b/src/mongo/db/pipeline/expression.cpp
@@ -528,7 +528,7 @@ namespace mongo {
}
void ExpressionCoerceToBool::addToBsonObj(
- BSONObjBuilder *pBuilder, string fieldName,
+ BSONObjBuilder *pBuilder, const std::string& fieldName,
bool requireExpression) const {
// Serializing as an $and expression which will become a CoerceToBool
BSONObjBuilder sub (pBuilder->subobjStart(fieldName));
@@ -789,7 +789,7 @@ namespace mongo {
}
void ExpressionConstant::addToBsonObj(
- BSONObjBuilder *pBuilder, string fieldName,
+ BSONObjBuilder *pBuilder, const std::string& fieldName,
bool requireExpression) const {
/*
If we don't need an expression, but can use a naked scalar,
@@ -1278,7 +1278,7 @@ namespace mongo {
}
void ExpressionObject::addToBsonObj(
- BSONObjBuilder *pBuilder, string fieldName,
+ BSONObjBuilder *pBuilder, const std::string& fieldName,
bool requireExpression) const {
BSONObjBuilder objBuilder (pBuilder->subobjStart(fieldName));
@@ -1391,7 +1391,7 @@ namespace mongo {
}
void ExpressionFieldPath::addToBsonObj(
- BSONObjBuilder *pBuilder, string fieldName,
+ BSONObjBuilder *pBuilder, const std::string& fieldName,
bool requireExpression) const {
pBuilder->append(fieldName, fieldPath.getPath(true));
}
@@ -1513,7 +1513,7 @@ namespace mongo {
}
void ExpressionFieldRange::addToBsonObj(
- BSONObjBuilder *pBuilder, string fieldName,
+ BSONObjBuilder *pBuilder, const std::string& fieldName,
bool requireExpression) const {
BuilderObj builder(pBuilder, fieldName);
addToBson(&builder);
@@ -2139,7 +2139,7 @@ namespace mongo {
}
void ExpressionNary::addToBsonObj(
- BSONObjBuilder *pBuilder, string fieldName,
+ BSONObjBuilder *pBuilder, const std::string& fieldName,
bool requireExpression) const {
BSONObjBuilder exprBuilder;
toBson(&exprBuilder, getOpName());
diff --git a/src/mongo/db/pipeline/expression.h b/src/mongo/db/pipeline/expression.h
index 49873f8d380..adbfc1826dc 100755
--- a/src/mongo/db/pipeline/expression.h
+++ b/src/mongo/db/pipeline/expression.h
@@ -95,7 +95,7 @@ namespace mongo {
field specification; See ExpressionConstant.
*/
virtual void addToBsonObj(
- BSONObjBuilder *pBuilder, string fieldName,
+ BSONObjBuilder *pBuilder, const std::string& fieldName,
bool requireExpression) const = 0;
/*
@@ -224,7 +224,7 @@ namespace mongo {
// virtuals from Expression
virtual intrusive_ptr<Expression> optimize();
virtual void addToBsonObj(
- BSONObjBuilder *pBuilder, string fieldName,
+ BSONObjBuilder *pBuilder, const std::string& fieldName,
bool requireExpression) const;
virtual void addToBsonArray(BSONArrayBuilder *pBuilder) const;
virtual void addDependencies(set<string>& deps, vector<string>* path=NULL) const;
@@ -368,7 +368,7 @@ namespace mongo {
virtual intrusive_ptr<const Value> evaluate(
const intrusive_ptr<Document> &pDocument) const;
virtual void addToBsonObj(
- BSONObjBuilder *pBuilder, string fieldName,
+ BSONObjBuilder *pBuilder, const std::string& fieldName,
bool requireExpression) const;
virtual void addToBsonArray(BSONArrayBuilder *pBuilder) const;
@@ -445,7 +445,7 @@ namespace mongo {
const intrusive_ptr<Document> &pDocument) const;
virtual const char *getOpName() const;
virtual void addToBsonObj(
- BSONObjBuilder *pBuilder, string fieldName,
+ BSONObjBuilder *pBuilder, const std::string& fieldName,
bool requireExpression) const;
virtual void addToBsonArray(BSONArrayBuilder *pBuilder) const;
@@ -547,7 +547,7 @@ namespace mongo {
virtual intrusive_ptr<const Value> evaluate(
const intrusive_ptr<Document> &pDocument) const;
virtual void addToBsonObj(
- BSONObjBuilder *pBuilder, string fieldName,
+ BSONObjBuilder *pBuilder, const std::string& fieldName,
bool requireExpression) const;
virtual void addToBsonArray(BSONArrayBuilder *pBuilder) const;
@@ -617,7 +617,7 @@ namespace mongo {
virtual intrusive_ptr<const Value> evaluate(
const intrusive_ptr<Document> &pDocument) const;
virtual void addToBsonObj(
- BSONObjBuilder *pBuilder, string fieldName,
+ BSONObjBuilder *pBuilder, const std::string& fieldName,
bool requireExpression) const;
virtual void addToBsonArray(BSONArrayBuilder *pBuilder) const;
virtual void toMatcherBson(BSONObjBuilder *pBuilder) const;
@@ -838,7 +838,7 @@ namespace mongo {
virtual intrusive_ptr<const Value> evaluate(
const intrusive_ptr<Document> &pDocument) const;
virtual void addToBsonObj(
- BSONObjBuilder *pBuilder, string fieldName,
+ BSONObjBuilder *pBuilder, const std::string& fieldName,
bool requireExpression) const;
virtual void addToBsonArray(BSONArrayBuilder *pBuilder) const;
diff --git a/src/mongo/db/pipeline/value.cpp b/src/mongo/db/pipeline/value.cpp
index ff75022a4fb..5ab0bd65c61 100644
--- a/src/mongo/db/pipeline/value.cpp
+++ b/src/mongo/db/pipeline/value.cpp
@@ -464,7 +464,7 @@ namespace mongo {
}
}
- void Value::addToBsonObj(BSONObjBuilder *pBuilder, string fieldName) const {
+ void Value::addToBsonObj(BSONObjBuilder *pBuilder, const std::string& fieldName) const {
BuilderObj objBuilder(pBuilder, fieldName);
addToBson(&objBuilder);
}
diff --git a/src/mongo/db/pipeline/value.h b/src/mongo/db/pipeline/value.h
index 293ba065fc1..6a99b673a70 100755
--- a/src/mongo/db/pipeline/value.h
+++ b/src/mongo/db/pipeline/value.h
@@ -185,7 +185,7 @@ namespace mongo {
/*
Add this value to the BSON object under construction.
*/
- void addToBsonObj(BSONObjBuilder *pBuilder, string fieldName) const;
+ void addToBsonObj(BSONObjBuilder *pBuilder, const std::string& fieldName) const;
/*
Add this field to the BSON array under construction.
diff --git a/src/mongo/db/queryoptimizer.cpp b/src/mongo/db/queryoptimizer.cpp
index 849c8064c85..3e84483ea9b 100644
--- a/src/mongo/db/queryoptimizer.cpp
+++ b/src/mongo/db/queryoptimizer.cpp
@@ -95,7 +95,7 @@ namespace mongo {
const shared_ptr<const ParsedQuery> &parsedQuery,
const BSONObj &startKey,
const BSONObj &endKey,
- string special ) {
+ const std::string& special ) {
auto_ptr<QueryPlan> ret( new QueryPlan( d, idxNo, frsp, originalQuery, order, parsedQuery,
special ) );
ret->init( originalFrsp, startKey, endKey );
@@ -108,7 +108,7 @@ namespace mongo {
const BSONObj &originalQuery,
const BSONObj &order,
const shared_ptr<const ParsedQuery> &parsedQuery,
- string special ) :
+ const std::string& special ) :
_d(d),
_idxNo(idxNo),
_frs( frsp.frsForIndex( _d, _idxNo ) ),
diff --git a/src/mongo/db/queryoptimizer.h b/src/mongo/db/queryoptimizer.h
index 64a5e3a75a0..89c80241547 100644
--- a/src/mongo/db/queryoptimizer.h
+++ b/src/mongo/db/queryoptimizer.h
@@ -51,7 +51,7 @@ namespace mongo {
shared_ptr<const ParsedQuery>(),
const BSONObj &startKey = BSONObj(),
const BSONObj &endKey = BSONObj(),
- string special="" );
+ const std::string& special="" );
/** Categorical classification of a QueryPlan's utility. */
enum Utility {
@@ -120,7 +120,7 @@ namespace mongo {
const BSONObj &originalQuery,
const BSONObj &order,
const shared_ptr<const ParsedQuery> &parsedQuery,
- string special );
+ const std::string& special );
void init( const FieldRangeSetPair *originalFrsp,
const BSONObj &startKey,
const BSONObj &endKey );
diff --git a/src/mongo/db/repl.cpp b/src/mongo/db/repl.cpp
index 8520d3fe674..e93d608c742 100644
--- a/src/mongo/db/repl.cpp
+++ b/src/mongo/db/repl.cpp
@@ -491,7 +491,7 @@ namespace mongo {
}
/* grab initial copy of a database from the master */
- void ReplSource::resync(string db) {
+ void ReplSource::resync(const std::string& db) {
string dummyNs = resyncDrop( db.c_str(), "internal" );
Client::Context ctx( dummyNs );
{
@@ -1155,7 +1155,7 @@ namespace mongo {
return true;
}
- bool OplogReader::connect(string hostName) {
+ bool OplogReader::connect(const std::string& hostName) {
if (conn() != 0) {
return true;
}
diff --git a/src/mongo/db/repl.h b/src/mongo/db/repl.h
index f621262989c..8000fcc6506 100644
--- a/src/mongo/db/repl.h
+++ b/src/mongo/db/repl.h
@@ -94,7 +94,7 @@ namespace mongo {
class ReplSource {
shared_ptr<ThreadPool> tp;
- void resync(string db);
+ void resync(const std::string& db);
/** @param alreadyLocked caller already put us in write lock if true */
void sync_pullOpLog_applyOperation(BSONObj& op, bool alreadyLocked);
diff --git a/src/mongo/db/repl/connections.h b/src/mongo/db/repl/connections.h
index 7254078ae34..22f2729d1fe 100644
--- a/src/mongo/db/repl/connections.h
+++ b/src/mongo/db/repl/connections.h
@@ -42,7 +42,7 @@ namespace mongo {
class ScopedConn {
public:
/** throws assertions if connect failure etc. */
- ScopedConn(string hostport);
+ ScopedConn(const std::string& hostport);
~ScopedConn() {
// conLock releases...
}
@@ -119,7 +119,7 @@ namespace mongo {
}
};
- inline ScopedConn::ScopedConn(string hostport) : _hostport(hostport) {
+ inline ScopedConn::ScopedConn(const std::string& hostport) : _hostport(hostport) {
bool first = false;
{
scoped_lock lk(mapMutex);
diff --git a/src/mongo/db/repl/health.h b/src/mongo/db/repl/health.h
index 0cb2f220d6f..52451a0c4c7 100644
--- a/src/mongo/db/repl/health.h
+++ b/src/mongo/db/repl/health.h
@@ -21,7 +21,13 @@
namespace mongo {
/* throws */
- bool requestHeartbeat(string setname, string fromHost, string memberFullName, BSONObj& result, int myConfigVersion, int& theirConfigVersion, bool checkEmpty = false);
+ bool requestHeartbeat(const std::string& setname,
+ const std::string& fromHost,
+ const std::string& memberFullName,
+ BSONObj& result,
+ int myConfigVersion,
+ int& theirConfigVersion,
+ bool checkEmpty = false);
struct HealthOptions {
HealthOptions() :
diff --git a/src/mongo/db/repl/heartbeat.cpp b/src/mongo/db/repl/heartbeat.cpp
index 875af670147..ee80eeee1a0 100644
--- a/src/mongo/db/repl/heartbeat.cpp
+++ b/src/mongo/db/repl/heartbeat.cpp
@@ -131,8 +131,13 @@ namespace mongo {
}
} cmdReplSetHeartbeat;
- bool requestHeartbeat(string setName, string from, string memberFullName, BSONObj& result,
- int myCfgVersion, int& theirCfgVersion, bool checkEmpty) {
+ bool requestHeartbeat(const std::string& setName,
+ const std::string& from,
+ const std::string& memberFullName,
+ BSONObj& result,
+ int myCfgVersion,
+ int& theirCfgVersion,
+ bool checkEmpty) {
if( replSetBlind ) {
return false;
}
diff --git a/src/mongo/db/repl/replset_commands.cpp b/src/mongo/db/repl/replset_commands.cpp
index 208601d59fd..a7dfa0c82c9 100644
--- a/src/mongo/db/repl/replset_commands.cpp
+++ b/src/mongo/db/repl/replset_commands.cpp
@@ -344,7 +344,7 @@ namespace mongo {
return startsWith( url , "/_replSet" );
}
- virtual void handle( const char *rq, string url, BSONObj params,
+ virtual void handle( const char *rq, const std::string& url, BSONObj params,
string& responseMsg, int& responseCode,
vector<string>& headers, const SockAddr &from ) {
diff --git a/src/mongo/db/repl/rs.cpp b/src/mongo/db/repl/rs.cpp
index 7045aedf1c0..9a7142cf8c7 100644
--- a/src/mongo/db/repl/rs.cpp
+++ b/src/mongo/db/repl/rs.cpp
@@ -54,7 +54,7 @@ namespace mongo {
}
}
- void ReplSetImpl::sethbmsg(string s, int logLevel) {
+ void ReplSetImpl::sethbmsg(const std::string& s, int logLevel) {
static time_t lastLogged;
_hbmsgTime = time(0);
@@ -318,7 +318,10 @@ namespace mongo {
/** @param cfgString <setname>/<seedhost1>,<seedhost2> */
- void parseReplsetCmdLine(string cfgString, string& setname, vector<HostAndPort>& seeds, set<HostAndPort>& seedSet ) {
+ void parseReplsetCmdLine(const std::string& cfgString,
+ string& setname,
+ vector<HostAndPort>& seeds,
+ set<HostAndPort>& seedSet ) {
const char *p = cfgString.c_str();
const char *slash = strchr(p, '/');
if( slash )
diff --git a/src/mongo/db/repl/rs.h b/src/mongo/db/repl/rs.h
index e0425b42a6c..eeb79b1fd0b 100644
--- a/src/mongo/db/repl/rs.h
+++ b/src/mongo/db/repl/rs.h
@@ -294,14 +294,17 @@ namespace mongo {
SP sp;
};
- void parseReplsetCmdLine(string cfgString, string& setname, vector<HostAndPort>& seeds, set<HostAndPort>& seedSet );
+ void parseReplsetCmdLine(const std::string& cfgString,
+ string& setname,
+ vector<HostAndPort>& seeds,
+ set<HostAndPort>& seedSet);
/** Parameter given to the --replSet command line option (parsed).
Syntax is "<setname>/<seedhost1>,<seedhost2>"
where setname is a name and seedhost is "<host>[:<port>]" */
class ReplSetCmdline {
public:
- ReplSetCmdline(string cfgString) { parseReplsetCmdLine(cfgString, setname, seeds, seedSet); }
+ ReplSetCmdline(const std::string& cfgString) { parseReplsetCmdLine(cfgString, setname, seeds, seedSet); }
string setname;
vector<HostAndPort> seeds;
set<HostAndPort> seedSet;
@@ -367,7 +370,7 @@ namespace mongo {
char _hbmsg[256]; // we change this unlocked, thus not an stl::string
time_t _hbmsgTime; // when it was logged
public:
- void sethbmsg(string s, int logLevel = 0);
+ void sethbmsg(const std::string& s, int logLevel = 0);
/**
* Election with Priorities
diff --git a/src/mongo/db/repl/rs_config.h b/src/mongo/db/repl/rs_config.h
index 945b422bc0f..a1e45f20edf 100644
--- a/src/mongo/db/repl/rs_config.h
+++ b/src/mongo/db/repl/rs_config.h
@@ -174,7 +174,7 @@ namespace mongo {
*/
struct TagSubgroup : boost::noncopyable {
~TagSubgroup(); // never called; not defined
- TagSubgroup(string nm) : name(nm) { }
+ TagSubgroup(const std::string& nm) : name(nm) { }
const string name;
OpTime last;
vector<TagClause*> clauses;
diff --git a/src/mongo/db/repl/rs_initialsync.cpp b/src/mongo/db/repl/rs_initialsync.cpp
index eb56c634722..aa4104c4cff 100644
--- a/src/mongo/db/repl/rs_initialsync.cpp
+++ b/src/mongo/db/repl/rs_initialsync.cpp
@@ -67,7 +67,7 @@ namespace mongo {
}
/* todo : progress metering to sethbmsg. */
- static bool clone(const char *master, string db, bool dataPass ) {
+ static bool clone(const char *master, const std::string& db, bool dataPass ) {
CloneOptions options;
options.fromDB = db;
diff --git a/src/mongo/db/restapi.cpp b/src/mongo/db/restapi.cpp
index 0f982b5fda8..da9a3fe48ef 100644
--- a/src/mongo/db/restapi.cpp
+++ b/src/mongo/db/restapi.cpp
@@ -49,7 +49,7 @@ namespace mongo {
url.find_last_of( '/' ) > 0;
}
- virtual void handle( const char *rq, string url, BSONObj params,
+ virtual void handle( const char *rq, const std::string& url, BSONObj params,
string& responseMsg, int& responseCode,
vector<string>& headers, const SockAddr &from ) {
@@ -110,7 +110,11 @@ namespace mongo {
responseMsg = ss.str();
}
- bool handleRESTQuery( string ns , string action , BSONObj & params , int & responseCode , stringstream & out ) {
+ bool handleRESTQuery( const std::string& ns,
+ const std::string& action,
+ BSONObj & params,
+ int & responseCode,
+ stringstream & out ) {
Timer t;
int html = _getOption( params["html"] , 0 );
@@ -208,7 +212,11 @@ namespace mongo {
}
// TODO Generate id and revision per couch POST spec
- void handlePost( string ns, const char *body, BSONObj& params, int & responseCode, stringstream & out ) {
+ void handlePost( const std::string& ns,
+ const char *body,
+ BSONObj& params,
+ int & responseCode,
+ stringstream & out ) {
try {
BSONObj obj = fromjson( body );
db.insert( ns.c_str(), obj );
diff --git a/src/mongo/s/config.cpp b/src/mongo/s/config.cpp
index fa3d43defce..966c977e6cc 100644
--- a/src/mongo/s/config.cpp
+++ b/src/mongo/s/config.cpp
@@ -427,7 +427,7 @@ namespace mongo {
return ci.getCM();
}
- void DBConfig::setPrimary( string s ) {
+ void DBConfig::setPrimary( const std::string& s ) {
scoped_lock lk( _lock );
_primary.reset( s );
_save();
@@ -711,7 +711,7 @@ namespace mongo {
ConfigServer::~ConfigServer() {
}
- bool ConfigServer::init( string s ) {
+ bool ConfigServer::init( const std::string& s ) {
vector<string> configdbs;
splitStringDelim( s, &configdbs, ',' );
return init( configdbs );
@@ -963,7 +963,7 @@ namespace mongo {
}
}
- string ConfigServer::getHost( string name , bool withPort ) {
+ string ConfigServer::getHost( const std::string& name , bool withPort ) {
if ( name.find( ":" ) != string::npos ) {
if ( withPort )
return name;
diff --git a/src/mongo/s/config.h b/src/mongo/s/config.h
index 7286e829e4a..788683e82d3 100644
--- a/src/mongo/s/config.h
+++ b/src/mongo/s/config.h
@@ -164,7 +164,7 @@ namespace mongo {
return _primary;
}
- void setPrimary( string s );
+ void setPrimary( const std::string& s );
bool load();
bool reload();
@@ -226,7 +226,7 @@ namespace mongo {
*/
bool init( vector<string> configHosts );
- bool init( string s );
+ bool init( const std::string& s );
bool allUp();
bool allUp( string& errmsg );
@@ -268,7 +268,7 @@ namespace mongo {
bool checkConfigServersConsistent( string& errmsg , int tries = 4 ) const;
private:
- string getHost( string name , bool withPort );
+ string getHost( const std::string& name , bool withPort );
vector<string> _config;
};
diff --git a/src/mongo/s/d_migrate.cpp b/src/mongo/s/d_migrate.cpp
index 138081fe376..7cca533cd16 100644
--- a/src/mongo/s/d_migrate.cpp
+++ b/src/mongo/s/d_migrate.cpp
@@ -256,7 +256,7 @@ namespace mongo {
_memoryUsed = 0;
}
- void start( string ns ,
+ void start( const std::string& ns ,
const BSONObj& min ,
const BSONObj& max ,
const BSONObj& shardKeyPattern ) {
@@ -650,7 +650,7 @@ namespace mongo {
} migrateFromStatus;
struct MigrateStatusHolder {
- MigrateStatusHolder( string ns ,
+ MigrateStatusHolder( const std::string& ns ,
const BSONObj& min ,
const BSONObj& max ,
const BSONObj& shardKeyPattern ) {
diff --git a/src/mongo/s/grid.cpp b/src/mongo/s/grid.cpp
index 4f40b8dfc79..5c972a7f5f0 100644
--- a/src/mongo/s/grid.cpp
+++ b/src/mongo/s/grid.cpp
@@ -134,7 +134,7 @@ namespace mongo {
return dbConfig;
}
- void Grid::removeDB( string database ) {
+ void Grid::removeDB( const std::string& database ) {
uassert( 10186 , "removeDB expects db name" , database.find( '.' ) == string::npos );
scoped_lock l( _lock );
_databases.erase( database );
@@ -554,7 +554,7 @@ namespace mongo {
_databases.clear();
}
- BSONObj Grid::getConfigSetting( string name ) const {
+ BSONObj Grid::getConfigSetting( const std::string& name ) const {
scoped_ptr<ScopedDbConnection> conn( ScopedDbConnection::getInternalScopedDbConnection(
configServer.getPrimary().getConnString() ) );
BSONObj result = conn->get()->findOne( ShardNS::settings, BSON( "_id" << name ) );
diff --git a/src/mongo/s/grid.h b/src/mongo/s/grid.h
index ba8886317bc..a3fd0c1cd5b 100644
--- a/src/mongo/s/grid.h
+++ b/src/mongo/s/grid.h
@@ -45,7 +45,7 @@ namespace mongo {
* removes db entry.
* on next getDBConfig call will fetch from db
*/
- void removeDB( string db );
+ void removeDB( const std::string& db );
/**
* removes db entry - only this DBConfig object will be removed,
@@ -106,7 +106,7 @@ namespace mongo {
* @param name identifies a particular type of configuration data.
* @return a BSON object containing the requested data.
*/
- BSONObj getConfigSetting( string name ) const;
+ BSONObj getConfigSetting( const std::string& name ) const;
unsigned long long getNextOpTime() const;
diff --git a/src/mongo/scripting/engine.cpp b/src/mongo/scripting/engine.cpp
index 9da44fe9b3e..7be1b471f2d 100644
--- a/src/mongo/scripting/engine.cpp
+++ b/src/mongo/scripting/engine.cpp
@@ -342,7 +342,7 @@ namespace mongo {
class PooledScope : public Scope {
public:
- PooledScope( const string pool , Scope * real ) : _pool( pool ) , _real( real ) {
+ PooledScope( const std::string& pool , Scope * real ) : _pool( pool ) , _real( real ) {
_real->loadStored( true );
};
virtual ~PooledScope() {
diff --git a/src/mongo/scripting/engine_spidermonkey.cpp b/src/mongo/scripting/engine_spidermonkey.cpp
index 4909ddd9763..a69c526b371 100644
--- a/src/mongo/scripting/engine_spidermonkey.cpp
+++ b/src/mongo/scripting/engine_spidermonkey.cpp
@@ -335,7 +335,11 @@ namespace mongo {
b.appendRegex( name , s.substr( 0 , end ) , s.substr( end + 1 ) );
}
- void append( BSONObjBuilder& b , string name , jsval val , BSONType oldType = EOO , const TraverseStack& stack=TraverseStack() ) {
+ void append( BSONObjBuilder& b,
+ const std::string& name,
+ jsval val,
+ BSONType oldType = EOO,
+ const TraverseStack& stack=TraverseStack() ) {
//cout << "name: " << name << "\t" << typeString( val ) << " oldType: " << oldType << endl;
switch ( JS_TypeOfValue( _context , val ) ) {
@@ -1857,7 +1861,7 @@ namespace mongo {
readOnlyRecv );
}
- void gotError( string s ) {
+ void gotError( const std::string& s ) {
_error = s;
}
diff --git a/src/mongo/shell/dbshell.cpp b/src/mongo/shell/dbshell.cpp
index 608c8ab77c7..0d8258b736a 100644
--- a/src/mongo/shell/dbshell.cpp
+++ b/src/mongo/shell/dbshell.cpp
@@ -243,7 +243,7 @@ void setupSignals() {
set_terminate( myterminate );
}
-string fixHost( string url , string host , string port ) {
+string fixHost( const std::string& url, const std::string& host, const std::string& port ) {
//cout << "fixHost url: " << url << " host: " << host << " port: " << port << endl;
if ( host.size() == 0 && port.size() == 0 ) {
@@ -264,10 +264,7 @@ string fixHost( string url , string host , string port ) {
::_exit(-1);
}
- if ( host.size() == 0 )
- host = "127.0.0.1";
-
- string newurl = host;
+ string newurl( ( host.size() == 0 ) ? "127.0.0.1" : host );
if ( port.size() > 0 )
newurl += ":" + port;
else if ( host.find(':') == string::npos ) {
@@ -288,14 +285,14 @@ bool isOpSymbol( char c ) {
return false;
}
-bool isUseCmd( string code ) {
+bool isUseCmd( const std::string& code ) {
string cmd = code;
if ( cmd.find( " " ) > 0 )
cmd = cmd.substr( 0 , cmd.find( " " ) );
return cmd == "use";
}
-bool isBalanced( string code ) {
+bool isBalanced( const std::string& code ) {
if (isUseCmd( code ))
return true; // don't balance "use <dbname>" in case dbname contains special chars
int curlyBrackets = 0;
diff --git a/src/mongo/util/assert_util.cpp b/src/mongo/util/assert_util.cpp
index b1c1d2321ca..49d1e7967d6 100644
--- a/src/mongo/util/assert_util.cpp
+++ b/src/mongo/util/assert_util.cpp
@@ -161,7 +161,7 @@ namespace mongo {
throw MsgAssertionException(msgid, msg);
}
- NOINLINE_DECL void streamNotGood( int code , string msg , std::ios& myios ) {
+ NOINLINE_DECL void streamNotGood( int code , const std::string& msg , std::ios& myios ) {
stringstream ss;
// errno might not work on all systems for streams
// if it doesn't for a system should deal with here
diff --git a/src/mongo/util/assert_util.h b/src/mongo/util/assert_util.h
index 8ae7ad8863f..c35911aa9e6 100644
--- a/src/mongo/util/assert_util.h
+++ b/src/mongo/util/assert_util.h
@@ -219,9 +219,9 @@ namespace mongo {
enum { ASSERT_ID_DUPKEY = 11000 };
/* throws a uassertion with an appropriate msg */
- MONGO_COMPILER_NORETURN void streamNotGood( int code , std::string msg , std::ios& myios );
+ MONGO_COMPILER_NORETURN void streamNotGood( int code, const std::string& msg, std::ios& myios );
- inline void assertStreamGood(unsigned msgid, std::string msg, std::ios& myios) {
+ inline void assertStreamGood(unsigned msgid, const std::string& msg, std::ios& myios) {
if( !myios.good() ) streamNotGood(msgid, msg, myios);
}
diff --git a/src/mongo/util/concurrency/msg.h b/src/mongo/util/concurrency/msg.h
index 6e8a3980246..6b1badd55e3 100644
--- a/src/mongo/util/concurrency/msg.h
+++ b/src/mongo/util/concurrency/msg.h
@@ -35,7 +35,7 @@ namespace mongo {
/** send a message to the port */
void send(lam);
- Server(string name) : m("server"), _name(name), rq(false) { }
+ Server(const std::string& name) : m("server"), _name(name), rq(false) { }
virtual ~Server() { }
/** send message but block until function completes */
diff --git a/src/mongo/util/concurrency/race.h b/src/mongo/util/concurrency/race.h
index 71bf7fde5dd..d5add6abe52 100644
--- a/src/mongo/util/concurrency/race.h
+++ b/src/mongo/util/concurrency/race.h
@@ -48,7 +48,7 @@ namespace mongo {
if( --n != 0 ) fail();
}
public:
- Block(string f, unsigned l) : n(0), ncalls(0), file(f), line(l) { }
+ Block(const std::string& f, unsigned l) : n(0), ncalls(0), file(f), line(l) { }
~Block() {
if( ncalls > 1000000 ) {
// just so we know if we are slowing things down
diff --git a/src/mongo/util/goodies.h b/src/mongo/util/goodies.h
index d2752dac72c..202d98920e1 100644
--- a/src/mongo/util/goodies.h
+++ b/src/mongo/util/goodies.h
@@ -82,7 +82,9 @@ namespace mongo {
if ( strlen(str) < l ) return false;
return strncmp(str, prefix, l) == 0;
}
- inline bool startsWith(string s, string p) { return startsWith(s.c_str(), p.c_str()); }
+ inline bool startsWith(const std::string& s, const std::string& p) {
+ return startsWith(s.c_str(), p.c_str());
+ }
inline bool endsWith(const char *p, const char *suffix) {
size_t a = strlen(p);
diff --git a/src/mongo/util/log.h b/src/mongo/util/log.h
index 15ab06dc0df..f983f71619d 100644
--- a/src/mongo/util/log.h
+++ b/src/mongo/util/log.h
@@ -94,7 +94,7 @@ namespace mongo {
return LabeledLevel( _label + string("::") + label, _level );
}
- LabeledLevel operator+( string& label ) const {
+ LabeledLevel operator+( const std::string& label ) const {
return LabeledLevel( _label + string("::") + label, _level );
}
diff --git a/src/mongo/util/logfile.cpp b/src/mongo/util/logfile.cpp
index d5aa99ee743..23b3b597e19 100644
--- a/src/mongo/util/logfile.cpp
+++ b/src/mongo/util/logfile.cpp
@@ -57,7 +57,7 @@ namespace mongo {
namespace mongo {
- LogFile::LogFile(string name, bool readwrite) : _name(name) {
+ LogFile::LogFile(const std::string& name, bool readwrite) : _name(name) {
_fd = CreateFile(
toNativeString(name.c_str()).c_str(),
(readwrite?GENERIC_READ:0)|GENERIC_WRITE,
@@ -147,7 +147,7 @@ namespace mongo {
namespace mongo {
- LogFile::LogFile(string name, bool readwrite) : _name(name) {
+ LogFile::LogFile(const std::string& name, bool readwrite) : _name(name) {
int options = O_CREAT
| (readwrite?O_RDWR:O_WRONLY)
#if defined(O_DIRECT)
diff --git a/src/mongo/util/logfile.h b/src/mongo/util/logfile.h
index e41ecc2f6ec..496b62c63e0 100644
--- a/src/mongo/util/logfile.h
+++ b/src/mongo/util/logfile.h
@@ -25,7 +25,7 @@ namespace mongo {
/** create the file and open. must not already exist.
throws UserAssertion on i/o error
*/
- LogFile(string name, bool readwrite = false);
+ LogFile(const std::string& name, bool readwrite = false);
/** closes */
~LogFile();
diff --git a/src/mongo/util/md5.hpp b/src/mongo/util/md5.hpp
index dc061719747..8974751054f 100644
--- a/src/mongo/util/md5.hpp
+++ b/src/mongo/util/md5.hpp
@@ -50,7 +50,7 @@ namespace mongo {
return digestToString( d );
}
- inline std::string md5simpledigest( string s ){
+ inline std::string md5simpledigest( const std::string& s ){
return md5simpledigest(s.data(), s.size());
}
diff --git a/src/mongo/util/mmap.cpp b/src/mongo/util/mmap.cpp
index bedbd70fb44..756f46e4c07 100644
--- a/src/mongo/util/mmap.cpp
+++ b/src/mongo/util/mmap.cpp
@@ -44,7 +44,7 @@ namespace mongo {
/* Create. Must not exist.
@param zero fill file with zeros when true
*/
- void* MemoryMappedFile::create(string filename, unsigned long long len, bool zero) {
+ void* MemoryMappedFile::create(const std::string& filename, unsigned long long len, bool zero) {
uassert( 13468, string("can't create file already exists ") + filename, ! boost::filesystem::exists(filename) );
void *p = map(filename.c_str(), len);
if( p && zero ) {
@@ -190,7 +190,7 @@ namespace mongo {
mmfiles.insert(this);
}
- void MongoFile::setFilename(string fn) {
+ void MongoFile::setFilename(const std::string& fn) {
LockMongoFilesExclusive lk;
verify( _filename.empty() );
_filename = fn;
diff --git a/src/mongo/util/mmap.h b/src/mongo/util/mmap.h
index 03be7b535e2..da5f28ef627 100644
--- a/src/mongo/util/mmap.h
+++ b/src/mongo/util/mmap.h
@@ -99,7 +99,7 @@ namespace mongo {
virtual bool isMongoMMF() { return false; }
string filename() const { return _filename; }
- void setFilename(string fn);
+ void setFilename(const std::string& fn);
private:
string _filename;
@@ -142,7 +142,7 @@ namespace mongo {
/** @return The MongoFile object associated with the specified file name. If no file is open
with the specified name, returns null.
*/
- MongoFile* findByPath(string path) {
+ MongoFile* findByPath(const std::string& path) {
map<string,MongoFile*>::iterator i = MongoFile::pathToFile.find(path);
return i == MongoFile::pathToFile.end() ? NULL : i->second;
}
@@ -185,7 +185,7 @@ namespace mongo {
/* Create. Must not exist.
@param zero fill file with zeros when true
*/
- void* create(string filename, unsigned long long len, bool zero);
+ void* create(const std::string& filename, unsigned long long len, bool zero);
void flush(bool sync);
virtual Flushable * prepareFlush();
diff --git a/src/mongo/util/mmap_win.cpp b/src/mongo/util/mmap_win.cpp
index 55cdc1ddeb8..50936f637de 100644
--- a/src/mongo/util/mmap_win.cpp
+++ b/src/mongo/util/mmap_win.cpp
@@ -328,7 +328,10 @@ namespace mongo {
class WindowsFlushable : public MemoryMappedFile::Flushable {
public:
- WindowsFlushable( void * view , HANDLE fd , string filename , boost::shared_ptr<mutex> flushMutex )
+ WindowsFlushable( void * view,
+ HANDLE fd,
+ const std::string& filename,
+ boost::shared_ptr<mutex> flushMutex )
: _view(view) , _fd(fd) , _filename(filename) , _flushMutex(flushMutex)
{}
diff --git a/src/mongo/util/mongoutils/html.h b/src/mongo/util/mongoutils/html.h
index b9757e8997e..d1c96c549b1 100644
--- a/src/mongo/util/mongoutils/html.h
+++ b/src/mongo/util/mongoutils/html.h
@@ -37,7 +37,7 @@ namespace mongoutils {
inline string _tr() { return "</tr>\n"; }
inline string tr() { return "<tr>"; }
- inline string tr(string a, string b) {
+ inline string tr(const std::string& a, const std::string& b) {
stringstream ss;
ss << "<tr><td>" << a << "</td><td>" << b << "</td></tr>\n";
return ss.str();
@@ -48,10 +48,10 @@ namespace mongoutils {
ss << "<td>" << x << "</td>";
return ss.str();
}
- inline string td(string x) {
+ inline string td(const std::string& x) {
return "<td>" + x + "</td>";
}
- inline string th(string x) {
+ inline string th(const std::string& x) {
return "<th>" + x + "</th>";
}
@@ -80,7 +80,7 @@ namespace mongoutils {
return ss.str();
}
- inline string start(string title) {
+ inline string start(const std::string& title) {
stringstream ss;
ss << "<html><head>\n<title>";
ss << title;
@@ -97,51 +97,53 @@ namespace mongoutils {
return ss.str();
}
- inline string red(string contentHtml, bool color=true) {
+ inline string red(const std::string& contentHtml, bool color=true) {
if( !color ) return contentHtml;
stringstream ss;
ss << "<span style=\"color:#A00;\">" << contentHtml << "</span>";
return ss.str();
}
- inline string grey(string contentHtml, bool color=true) {
+ inline string grey(const std::string& contentHtml, bool color=true) {
if( !color ) return contentHtml;
stringstream ss;
ss << "<span style=\"color:#888;\">" << contentHtml << "</span>";
return ss.str();
}
- inline string blue(string contentHtml, bool color=true) {
+ inline string blue(const std::string& contentHtml, bool color=true) {
if( !color ) return contentHtml;
stringstream ss;
ss << "<span style=\"color:#00A;\">" << contentHtml << "</span>";
return ss.str();
}
- inline string yellow(string contentHtml, bool color=true) {
+ inline string yellow(const std::string& contentHtml, bool color=true) {
if( !color ) return contentHtml;
stringstream ss;
ss << "<span style=\"color:#A80;\">" << contentHtml << "</span>";
return ss.str();
}
- inline string green(string contentHtml, bool color=true) {
+ inline string green(const std::string& contentHtml, bool color=true) {
if( !color ) return contentHtml;
stringstream ss;
ss << "<span style=\"color:#0A0;\">" << contentHtml << "</span>";
return ss.str();
}
- inline string p(string contentHtml) {
+ inline string p(const std::string& contentHtml) {
stringstream ss;
ss << "<p>" << contentHtml << "</p>\n";
return ss.str();
}
- inline string h2(string contentHtml) {
+ inline string h2(const std::string& contentHtml) {
stringstream ss;
ss << "<h2>" << contentHtml << "</h2>\n";
return ss.str();
}
/* does NOT escape the strings. */
- inline string a(string href, string title="", string contentHtml = "") {
+ inline string a(const std::string& href,
+ const std::string& title="",
+ const std::string& contentHtml = "") {
stringstream ss;
ss << "<a";
if( !href.empty() ) ss << " href=\"" << href << '"';
diff --git a/src/mongo/util/mongoutils/str.h b/src/mongo/util/mongoutils/str.h
index 9859f92f673..35589468309 100644
--- a/src/mongo/util/mongoutils/str.h
+++ b/src/mongo/util/mongoutils/str.h
@@ -37,8 +37,6 @@ namespace mongoutils {
namespace str {
- typedef std::string string;
-
/** the idea here is to make one liners easy. e.g.:
return str::stream() << 1 << ' ' << 2;
@@ -67,13 +65,15 @@ namespace mongoutils {
}
return true;
}
- inline bool startsWith(string s, string p) { return startsWith(s.c_str(), p.c_str()); }
+ inline bool startsWith(const std::string& s, const std::string& p) {
+ return startsWith(s.c_str(), p.c_str());
+ }
// while these are trivial today use in case we do different wide char things later
inline bool startsWith(const char *p, char ch) { return *p == ch; }
- inline bool startsWith(string s, char ch) { return startsWith(s.c_str(), ch); }
+ inline bool startsWith(const std::string& s, char ch) { return startsWith(s.c_str(), ch); }
- inline bool endsWith(string s, string p) {
+ inline bool endsWith(const std::string& s, const std::string& p) {
int l = p.size();
int x = s.size();
if( x < l ) return false;
@@ -91,9 +91,9 @@ namespace mongoutils {
const char *p = strchr(s, x);
return (p != 0) ? p+1 : "";
}
- inline string after(const string& s, char x) {
+ inline std::string after(const std::string& s, char x) {
const char *p = strchr(s.c_str(), x);
- return (p != 0) ? string(p+1) : "";
+ return (p != 0) ? std::string(p+1) : "";
}
/** find string x, and return rest of string thereafter, or "" if not found */
@@ -101,30 +101,30 @@ namespace mongoutils {
const char *p = strstr(s, x);
return (p != 0) ? p+strlen(x) : "";
}
- inline string after(string s, string x) {
+ inline std::string after(const std::string& s, const std::string& x) {
const char *p = strstr(s.c_str(), x.c_str());
- return (p != 0) ? string(p+x.size()) : "";
+ return (p != 0) ? std::string(p+x.size()) : "";
}
/** @return true if s contains x
* These should not be used with strings containing NUL bytes
*/
- inline bool contains(string s, string x) {
+ inline bool contains(const std::string& s, const std::string& x) {
return strstr(s.c_str(), x.c_str()) != 0;
}
- inline bool contains(string s, char x) {
+ inline bool contains(const std::string& s, char x) {
verify(x != '\0'); // this expects c-strings so don't use when looking for NUL bytes
return strchr(s.c_str(), x) != 0;
}
/** @return everything before the character x, else entire string */
- inline string before(const string& s, char x) {
+ inline std::string before(const std::string& s, char x) {
const char *p = strchr(s.c_str(), x);
return (p != 0) ? s.substr(0, p-s.c_str()) : s;
}
/** @return everything before the string x, else entire string */
- inline string before(const string& s, const string& x) {
+ inline std::string before(const std::string& s, const std::string& x) {
const char *p = strstr(s.c_str(), x.c_str());
return (p != 0) ? s.substr(0, p-s.c_str()) : s;
}
@@ -142,11 +142,11 @@ namespace mongoutils {
}
return ofs;
}
- inline int shareCommonPrefix(const string &a, const string &b)
+ inline int shareCommonPrefix(const std::string &a, const std::string &b)
{ return shareCommonPrefix(a.c_str(), b.c_str()); }
/** string to unsigned. zero if not a number. can end with non-num chars */
- inline unsigned toUnsigned(const string& a) {
+ inline unsigned toUnsigned(const std::string& a) {
unsigned x = 0;
const char *p = a.c_str();
while( 1 ) {
@@ -163,32 +163,32 @@ namespace mongoutils {
and R is empty.
@return true if char found
*/
- inline bool splitOn(const string &s, char c, string& L, string& R) {
+ inline bool splitOn(const std::string &s, char c, std::string& L, std::string& R) {
const char *start = s.c_str();
const char *p = strchr(start, c);
if( p == 0 ) {
L = s; R.clear();
return false;
}
- L = string(start, p-start);
- R = string(p+1);
+ L = std::string(start, p-start);
+ R = std::string(p+1);
return true;
}
/** split scanning reverse direction. Splits ONCE ONLY. */
- inline bool rSplitOn(const string &s, char c, string& L, string& R) {
+ inline bool rSplitOn(const std::string &s, char c, std::string& L, std::string& R) {
const char *start = s.c_str();
const char *p = strrchr(start, c);
if( p == 0 ) {
L = s; R.clear();
return false;
}
- L = string(start, p-start);
- R = string(p+1);
+ L = std::string(start, p-start);
+ R = std::string(p+1);
return true;
}
/** @return number of occurrences of c in s */
- inline unsigned count( const string& s , char c ) {
+ inline unsigned count( const std::string& s , char c ) {
unsigned n=0;
for ( unsigned i=0; i<s.size(); i++ )
if ( s[i] == c )
@@ -197,15 +197,15 @@ namespace mongoutils {
}
/** trim leading spaces. spaces only, not tabs etc. */
- inline string ltrim(const string& s) {
+ inline std::string ltrim(const std::string& s) {
const char *p = s.c_str();
while( *p == ' ' ) p++;
return p;
}
/** remove trailing chars in place */
- inline void stripTrailing(string& s, const char *chars) {
- string::iterator i = s.end();
+ inline void stripTrailing(std::string& s, const char *chars) {
+ std::string::iterator i = s.end();
while( s.begin() != i ) {
i--;
if( contains(chars, *i) ) {
diff --git a/src/mongo/util/net/hostandport.h b/src/mongo/util/net/hostandport.h
index 11acf5def25..f1e6bba58bb 100644
--- a/src/mongo/util/net/hostandport.h
+++ b/src/mongo/util/net/hostandport.h
@@ -33,10 +33,10 @@ namespace mongo {
/** From a string hostname[:portnumber]
Throws user assertion if bad config string or bad port #.
*/
- HostAndPort(string s);
+ HostAndPort(const std::string& s);
/** @param p port number. -1 is ok to use default. */
- HostAndPort(string h, int p /*= -1*/) : _host(h), _port(p) {
+ HostAndPort(const std::string& h, int p /*= -1*/) : _host(h), _port(p) {
verify( !str::startsWith(h, '#') );
}
@@ -172,7 +172,7 @@ namespace mongo {
}
}
- inline HostAndPort::HostAndPort(string s) {
+ inline HostAndPort::HostAndPort(const std::string& s) {
init(s.c_str());
}
diff --git a/src/mongo/util/net/httpclient.cpp b/src/mongo/util/net/httpclient.cpp
index e94475a1940..d39f10dba69 100644
--- a/src/mongo/util/net/httpclient.cpp
+++ b/src/mongo/util/net/httpclient.cpp
@@ -29,11 +29,11 @@ namespace mongo {
#define HD(x)
- int HttpClient::get( string url , Result * result ) {
+ int HttpClient::get( const std::string& url , Result * result ) {
return _go( "GET" , url , 0 , result );
}
- int HttpClient::post( string url , string data , Result * result ) {
+ int HttpClient::post( const std::string& url , const std::string& data , Result * result ) {
return _go( "POST" , url , data.c_str() , result );
}
diff --git a/src/mongo/util/net/httpclient.h b/src/mongo/util/net/httpclient.h
index 4f6dd0d718d..08cee82d5d2 100644
--- a/src/mongo/util/net/httpclient.h
+++ b/src/mongo/util/net/httpclient.h
@@ -59,12 +59,12 @@ namespace mongo {
/**
* @return response code
*/
- int get( string url , Result * result = 0 );
+ int get( const std::string& url , Result * result = 0 );
/**
* @return response code
*/
- int post( string url , string body , Result * result = 0 );
+ int post( const std::string& url , const std::string& body , Result * result = 0 );
private:
int _go( const char * command , string url , const char * body , Result * result );
diff --git a/src/mongo/util/net/listen.h b/src/mongo/util/net/listen.h
index 4b98045e5a7..2ce8398a79c 100644
--- a/src/mongo/util/net/listen.h
+++ b/src/mongo/util/net/listen.h
@@ -152,7 +152,7 @@ namespace mongo {
scoped_lock lk( _mutex );
_sockets->insert( sock );
}
- void addPath( string path ) {
+ void addPath( const std::string& path ) {
scoped_lock lk( _mutex );
_socketPaths->insert( path );
}
diff --git a/src/mongo/util/net/miniwebserver.cpp b/src/mongo/util/net/miniwebserver.cpp
index c0d1bf24fc4..3888c059914 100644
--- a/src/mongo/util/net/miniwebserver.cpp
+++ b/src/mongo/util/net/miniwebserver.cpp
@@ -175,7 +175,7 @@ namespace mongo {
}
}
- string MiniWebServer::getHeader( const char * req , string wanted ) {
+ string MiniWebServer::getHeader( const char * req , const std::string& wanted ) {
const char * headers = strchr( req , '\n' );
if ( ! headers )
return "";
diff --git a/src/mongo/util/net/miniwebserver.h b/src/mongo/util/net/miniwebserver.h
index 7690dfa2f7a..2f7d68cf3a9 100644
--- a/src/mongo/util/net/miniwebserver.h
+++ b/src/mongo/util/net/miniwebserver.h
@@ -46,11 +46,11 @@ namespace mongo {
static string parseURL( const char * buf );
static string parseMethod( const char * headers );
- static string getHeader( const char * headers , string name );
+ static string getHeader( const char * headers , const std::string& name );
static const char *body( const char *buf );
static string urlDecode(const char* s);
- static string urlDecode(string s) {return urlDecode(s.c_str());}
+ static string urlDecode(const std::string& s) {return urlDecode(s.c_str());}
private:
void accepted(boost::shared_ptr<Socket> psocket, long long connectionId );
diff --git a/src/mongo/util/net/sock.h b/src/mongo/util/net/sock.h
index 436998e7a09..fc13017b97f 100644
--- a/src/mongo/util/net/sock.h
+++ b/src/mongo/util/net/sock.h
@@ -132,7 +132,7 @@ namespace mongo {
public:
const enum Type { CLOSED , RECV_ERROR , SEND_ERROR, RECV_TIMEOUT, SEND_TIMEOUT, FAILED_STATE, CONNECT_ERROR } _type;
- SocketException( Type t , string server , int code = 9001 , string extra="" )
+ SocketException( Type t , const std::string& server , int code = 9001 , const std::string& extra="" )
: DBException( (string)"socket exception [" + _getStringType( t ) + "] for " + server, code ),
_type(t),
_server(server),
diff --git a/src/mongo/util/ntservice.cpp b/src/mongo/util/ntservice.cpp
index 92dfa7d8990..1eed0b7459b 100644
--- a/src/mongo/util/ntservice.cpp
+++ b/src/mongo/util/ntservice.cpp
@@ -40,7 +40,7 @@ namespace mongo {
// returns true if the service is started.
bool serviceParamsCheck(
boost::program_options::variables_map& params,
- const std::string dbpath,
+ const std::string& dbpath,
const ntServiceDefaultStrings& defaultStrings,
const vector<string>& disallowedOptions,
int argc,
@@ -177,7 +177,7 @@ namespace mongo {
const wstring& serviceDesc,
const wstring& serviceUser,
const wstring& servicePassword,
- const std::string dbpath,
+ const std::string& dbpath,
int argc,
char* argv[]
) {
diff --git a/src/mongo/util/ntservice.h b/src/mongo/util/ntservice.h
index 4492c317e27..8ce43feeed3 100644
--- a/src/mongo/util/ntservice.h
+++ b/src/mongo/util/ntservice.h
@@ -32,7 +32,7 @@ namespace mongo {
typedef bool ( *ServiceCallback )( void );
bool serviceParamsCheck(
boost::program_options::variables_map& params,
- const std::string dbpath,
+ const std::string& dbpath,
const ntServiceDefaultStrings& defaultStrings,
const vector<string>& disallowedOptions,
int argc,
@@ -50,7 +50,7 @@ namespace mongo {
const std::wstring& serviceDesc,
const std::wstring& serviceUser,
const std::wstring& servicePassword,
- const std::string dbpath,
+ const std::string& dbpath,
int argc,
char* argv[]
);
diff --git a/src/mongo/util/paths.h b/src/mongo/util/paths.h
index 5ba3c64d8ae..e7ca6d5d17c 100644
--- a/src/mongo/util/paths.h
+++ b/src/mongo/util/paths.h
@@ -39,7 +39,7 @@ namespace mongo {
bool empty() const { return _p.empty(); }
- static RelativePath fromRelativePath(string f) {
+ static RelativePath fromRelativePath(const std::string& f) {
RelativePath rp;
rp._p = f;
return rp;
diff --git a/src/mongo/util/progress_meter.h b/src/mongo/util/progress_meter.h
index 50a1133a5cb..6da0c14fc0a 100644
--- a/src/mongo/util/progress_meter.h
+++ b/src/mongo/util/progress_meter.h
@@ -46,7 +46,7 @@ namespace mongo {
*/
bool hit( int n = 1 );
- void setUnits( std::string units ) { _units = units; }
+ void setUnits( const std::string& units ) { _units = units; }
std::string getUnit() const { return _units; }
void setTotalWhileRunning( unsigned long long total ) {
diff --git a/src/mongo/util/ramlog.cpp b/src/mongo/util/ramlog.cpp
index 12e8ba0921e..e61d78863f0 100644
--- a/src/mongo/util/ramlog.cpp
+++ b/src/mongo/util/ramlog.cpp
@@ -25,7 +25,7 @@ namespace mongo {
using namespace mongoutils;
- RamLog::RamLog( string name ) : _name(name), _lastWrite(0) {
+ RamLog::RamLog( const std::string& name ) : _name(name), _lastWrite(0) {
h = 0; n = 0;
for( int i = 0; i < N; i++ )
lines[i][C-1] = 0;
@@ -47,7 +47,7 @@ namespace mongo {
}
- void RamLog::write(LogLevel ll, const string& str) {
+ void RamLog::write(LogLevel ll, const std::string& str) {
_lastWrite = time(0);
char *p = lines[(h+n)%N];
@@ -96,7 +96,7 @@ namespace mongo {
return v[i];
}
- string RamLog::color(string line) {
+ string RamLog::color(const std::string& line) {
string s = str::after(line, "replSet ");
if( str::startsWith(s, "warning") || startsWith(s, "error") )
return html::red(line);
@@ -161,7 +161,7 @@ namespace mongo {
// static things
// ---------------
- RamLog* RamLog::get( string name ) {
+ RamLog* RamLog::get( const std::string& name ) {
if ( ! _named )
return 0;
diff --git a/src/mongo/util/ramlog.h b/src/mongo/util/ramlog.h
index d3d5c8fbb4e..889f4f6a4e2 100644
--- a/src/mongo/util/ramlog.h
+++ b/src/mongo/util/ramlog.h
@@ -23,7 +23,7 @@ namespace mongo {
class RamLog : public Tee {
public:
- RamLog( string name );
+ RamLog( const std::string& name );
virtual void write(LogLevel ll, const string& str);
@@ -31,7 +31,7 @@ namespace mongo {
void toHTML(stringstream& s);
- static RamLog* get( string name );
+ static RamLog* get( const std::string& name );
static void getNames( vector<string>& names );
time_t lastWrite() { return _lastWrite; } // 0 if no writes
@@ -39,7 +39,7 @@ namespace mongo {
protected:
static int repeats(const vector<const char *>& v, int i);
static string clean(const vector<const char *>& v, int i, string line="");
- static string color(string line);
+ static string color(const std::string& line);
/* turn http:... into an anchor */
static string linkify(const char *s);
diff --git a/src/mongo/util/text.cpp b/src/mongo/util/text.cpp
index 9308c0a333a..59592b9a49d 100644
--- a/src/mongo/util/text.cpp
+++ b/src/mongo/util/text.cpp
@@ -99,7 +99,7 @@ namespace mongo {
}
- bool isValidUTF8(string s) {
+ bool isValidUTF8(const std::string& s) {
return isValidUTF8(s.c_str());
}
diff --git a/src/mongo/util/text.h b/src/mongo/util/text.h
index 96f88285299..40ee2cbae2d 100644
--- a/src/mongo/util/text.h
+++ b/src/mongo/util/text.h
@@ -70,7 +70,7 @@ namespace mongo {
* guarantee that the codepoints are valid.
*/
bool isValidUTF8(const char *s);
- bool isValidUTF8(std::string s);
+ bool isValidUTF8(const std::string& s);
// expect that n contains a base ten number and nothing else after it
// NOTE win version hasn't been tested directly