Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-11336

Minor optimization for RegEx parsing

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Won't Fix
    • Affects Version/s: 2.5.3
    • Fix Version/s: None
    • Component/s: Querying
    • Labels:
    • Environment:

      Description

      Problem:
      Appears to be a duplication of confirming if an expression is a RegEx. Its the first check in _parseRegexElement which is then checked as the first step of RegexMatchExpression.init()

      expression_leaf_parser.cpp:441

          StatusWithMatchExpression MatchExpressionParser::_parseRegexElement( const char* name,
                                                                     const BSONElement& e ) {
              if ( e.type() != RegEx )
                  return StatusWithMatchExpression( ErrorCodes::BadValue, "not a regex" );
       
              std::auto_ptr<RegexMatchExpression> temp( new RegexMatchExpression() );
              Status s = temp->init( name, e.regex(), e.regexFlags() );
              if ( !s.isOK() )
                  return StatusWithMatchExpression( s );
              return StatusWithMatchExpression( temp.release() );
          }

      exprssion_leaf.cpp:201

          Status RegexMatchExpression::init( const StringData& path, const BSONElement& e ) {
              if ( e.type() != RegEx )
                  return Status( ErrorCodes::BadValue, "regex not a regex" );
              return init( path, e.regex(), e.regexFlags() );
          }

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: