Uploaded image for project: 'C++ Standard Library'
  1. C++ Standard Library
  2. STDCXX-176

std::string::find() inefficient

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 4.1.3
    • Fix Version/s: 4.1.4
    • Component/s: 21. Strings
    • Labels:
      None
    • Environment:

      all

      Description

      The naive implementation of std::basic_string::find() in string.cc is quite inefficient:

      for (size_type _xpos = __pos; __xpos + __n <= size (); ++_xpos)

      { if (!traits_type::compare (_C_data + __xpos, __s, __n)) return __xpos; }

      return npos;

      See http://svn.apache.org/viewcvs.cgi/incubator/stdcxx/branches/4.1.3/include/string.cc?rev=366577&view=markup

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                sebor Martin Sebor
                Reporter:
                sebor Martin Sebor
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: