From bd2991edf2b80f22afe93db2d4cd7ec8493760d0 Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Mon, 1 Mar 2010 19:53:22 -0500 Subject: use addRegex everywhere --- db/matcher.cpp | 20 ++++---------------- db/matcher.h | 2 +- 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); -- cgit v1.2.1