Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-100239

We repeatedly foldCase() the needles

    XMLWordPrintable

Details

    • 13
    • d8387fc538 (qt/qtbase/dev) d8387fc538 (qt/tqtc-qtbase/dev)
    • Foundation Sprint 62, Foundation Sprint 63, Foundation Sprint 64, Foundation Sprint 65, Foundation Sprint 66

    Description

      Both in QStringMatcher, as well as in findString(), we foldCase() the needle characters over and over again. In at least two cases, that could be easily avoided:

      • in Boyer-Moore searches, we can store not the pattern, but the case-folded pattern, so we only need to foldCase() haystack characters, knowing needle characters will already be case-folded. This change is rather localized, but would break the QStringMatcher API (pattern() wouldn't return the setPattern() argument, but the case-folded version). Probably can write a private duplicate that both QStringMatcher and internal code use.
      • When converting the encoding of the needle, we can do the case-folding as we re-code

      In both cases, we'd need special comparison functions that "know" that the needle is already case-folded. QCollator is a bit heavy-weight for that, though.

      Since the goal is to make searching and comparison noexcept, we need to limit the storage of the case-folded needle to some static max length, say, 256, and, if the needle is longer, generate candidates using the 256-char prefix, and confirm them with a haystack.sliced(candidatePos + 256).startsWith(needle.sliced(256)).

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            oyheskes Øystein Heskestad
            mmutz Marc Mutz
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes