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

Refactor std::string casts in PlanCacheSizeParameter::parse

    • Type: Icon: Task Task
    • Resolution: Won't Do
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Query Execution

      Currently, in PlanCacheSizeParameter::parse in src/mongo/db/query/plan_cache_size_parameter.cpp, we take an std::string reference as input and use it to match against a regular expression. We also need to do a lot of std::string conversions on the output.

      However, we don't really need std::string.  matchView will accept a StringData as input. Then the std::stod can be changed to exploit our knowledge of m[1]'s format.
      We know it's digits, a dot, and then maybe more digits.

      The parseUnitString function should just be changed to take StringData.

      double size;
      invariant(!std::from_chars<double>( 
          m[1].begin(), m[1].end(), size, 
          std::chars_format::fixed).ec);
      auto statusWithUnit = parseUnitString(m[2]); 

      We will use an invariant instead of uassert because it would indicate that our compiled-in regex was wrong, in that it didn't have the right captures to produce a valid fixed point number.

            Assignee:
            backlog-query-execution [DO NOT USE] Backlog - Query Execution
            Reporter:
            jennifer.peshansky@mongodb.com Jennifer Peshansky (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: