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

Optimize prepending of UTF-8 to QString

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • P2: Important
    • None
    • None
    • None

    Description

      This is only loosely connected to search and compare, but there we go...

      The problem with inserting a UTF-8 sequence in the middle of a UTF-16 one is that the number of UTF-16 characters needed to represent the UTF-8 sequence isn't known beforehand, so we need to make space for the maximum number of elements, and then move the tail back to the end of the inserted sequence (unlike UTF-16 and L1 insertions, where the number of characters required is known beforehand). This is QTBUG-108546.

      Specifically for prepending, though, given that QString has a prepend optimization where free space may be at the front, we can do better: if the free space at the front is ≥ the maximum expanded size of the UTF-8 string, we could decode the UTF-8 sequence, and write the UTF-16 characters, backwards, moving the begin() of the QString the same way that append() moves the end(). And we'd write each character only once.

      Acceptance criterium: QString::prepend(UTF-8-ish) writes each character of the result string at most once (incl. detach, cf. QTBUG-106186) where UTF-8-ish includes const char/8_t *, QByteArray/View, QUtf8String/View.

      Attachments

        Issue Links

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

          Activity

            People

              cnn Qt Core & Network
              mmutz Marc Mutz
              Vladimir Minenko Vladimir Minenko
              Alex Blasche Alex Blasche
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes