summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2010-03-01 19:53:22 -0500
committerMathias Stearn <mathias@10gen.com>2010-03-01 19:53:43 -0500
commitbd2991edf2b80f22afe93db2d4cd7ec8493760d0 (patch)
tree4764dbe628e0aa2ec691b331fb3613b32372f7b4
parent15a53a9af53cb045677862fe0acd40dda2f88cde (diff)
downloadmongo-bd2991edf2b80f22afe93db2d4cd7ec8493760d0.tar.gz
use addRegex everywhere
-rw-r--r--db/matcher.cpp20
-rw-r--r--db/matcher.h2
2 files changed, 5 insertions, 17 deletions
diff --git a/db/matcher.cpp b/db/matcher.cpp
index 85ad9bccea3..eb809c4757a 100644
--- a/db/matcher.cpp
+++ b/db/matcher.cpp
@@ -164,17 +164,12 @@ namespace mongo {
}
- void Matcher::addRegex( const BSONElement &e, const char *fieldName, bool isNot ) {
- if ( fieldName == 0 )
- fieldName = e.fieldName();
+ void Matcher::addRegex(const char *fieldName, const char *regex, const char *flags, bool isNot){
if ( nRegex >= 4 ) {
out() << "ERROR: too many regexes in query" << endl;
}
else {
- const char* regex = e.regex();
- const char* flags = e.regexFlags();
-
RegexMatcher& rm = regexs[nRegex];
rm.re = new pcrecpp::RE(regex, flags2options(flags));
rm.fieldName = fieldName;
@@ -301,7 +296,7 @@ namespace mongo {
}
if ( e.type() == RegEx ) {
- addRegex( e );
+ addRegex( e.fieldName(), e.regex(), e.regexFlags() );
continue;
}
@@ -336,7 +331,7 @@ namespace mongo {
break;
}
case RegEx:
- addRegex( fe, e.fieldName(), true );
+ addRegex( e.fieldName(), fe.regex(), fe.regexFlags(), true );
break;
default:
uassert( 13031, "invalid use of $not", false );
@@ -354,14 +349,7 @@ namespace mongo {
}
}
if (regex){
- if ( nRegex >= 4 ) {
- out() << "ERROR: too many regexes in query" << endl;
- } else {
- RegexMatcher& rm = regexs[nRegex];
- rm.re = new pcrecpp::RE(regex, flags2options(flags));
- rm.fieldName = e.fieldName();
- nRegex++;
- }
+ addRegex(e.fieldName(), regex, flags);
}
if ( isOperator )
continue;
diff --git a/db/matcher.h b/db/matcher.h
index 98f550c98ec..6f1e8b82c58 100644
--- a/db/matcher.h
+++ b/db/matcher.h
@@ -134,7 +134,7 @@ namespace mongo {
basics.push_back( ElementMatcher( e , c, isNot ) );
}
- void addRegex(const BSONElement &e, const char *fieldName = 0, bool isNot = false);
+ void addRegex(const char *fieldName, const char *regex, const char *flags, bool isNot = false);
bool addOp( const BSONElement &e, const BSONElement &fe, bool isNot, const char *& regex, const char *&flags );
int valuesMatch(const BSONElement& l, const BSONElement& r, int op, const ElementMatcher& bm);