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

Minor optimization for RegEx parsing

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

      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() );
          }
      

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            alvin Alvin Richards (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: