summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2010-06-09 12:08:02 -0400
committerEliot Horowitz <eliot@10gen.com>2010-06-09 12:08:02 -0400
commiteebb327db819bc0fe16fc32e8f144c2d71ca5a3c (patch)
tree32af67b7c646149f70c50de2ca5ad396e9811fd1 /db
parent3d046e9a94b84fd7c651867a9bc73516791f4689 (diff)
downloadmongo-eebb327db819bc0fe16fc32e8f144c2d71ca5a3c.tar.gz
make check for $ faster
Diffstat (limited to 'db')
-rw-r--r--db/cloner.cpp5
-rw-r--r--db/pdfile.cpp2
-rw-r--r--db/pdfile.h10
3 files changed, 12 insertions, 5 deletions
diff --git a/db/cloner.cpp b/db/cloner.cpp
index 8dd06bd9c4e..c23a3d5f32b 100644
--- a/db/cloner.cpp
+++ b/db/cloner.cpp
@@ -234,10 +234,7 @@ namespace mongo {
continue;
}
}
- if( strcmp( from_name, "local.oplog.$main" ) == 0 ) {
- // nothing - want to clone this one
- } else if( strchr(from_name, '$') ) {
- // don't clone index namespaces -- we take care of those separately below.
+ if( ! nsDollarCheck( from_name ) ){
log(2) << "\t\t not cloning because has $ " << endl;
continue;
}
diff --git a/db/pdfile.cpp b/db/pdfile.cpp
index 377162670b1..8567783d6df 100644
--- a/db/pdfile.cpp
+++ b/db/pdfile.cpp
@@ -1349,7 +1349,7 @@ namespace mongo {
*/
DiskLoc DataFileMgr::insert(const char *ns, const void *obuf, int len, bool god, const BSONElement &writeId, bool mayAddIndex) {
bool wouldAddIndex = false;
- massert( 10093 , "cannot insert into reserved $ collection", god || strchr(ns, '$') == 0 || strcmp( ns, "local.oplog.$main" ) == 0 );
+ massert( 10093 , "cannot insert into reserved $ collection", god || nsDollarCheck( ns ) );
uassert( 10094 , "invalid ns", strchr( ns , '.' ) > 0 );
const char *sys = strstr(ns, "system.");
if ( sys ) {
diff --git a/db/pdfile.h b/db/pdfile.h
index dd8f04997f6..5cef15bd927 100644
--- a/db/pdfile.h
+++ b/db/pdfile.h
@@ -485,5 +485,15 @@ namespace mongo {
void ensureHaveIdIndex(const char *ns);
bool dropIndexes( NamespaceDetails *d, const char *ns, const char *name, string &errmsg, BSONObjBuilder &anObjBuilder, bool maydeleteIdIndex );
+
+
+ /**
+ * @return true if ns is ok
+ */
+ inline bool nsDollarCheck( const char* ns ){
+ if ( strchr( ns , '$' ) == 0 )
+ return true;
+ return strcmp( ns, "local.oplog.$main" ) == 0;
+ }
} // namespace mongo