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

As a user of Qt, I'd like the string-like classes to have substringing actions, not just transformations

    XMLWordPrintable

    Details

    • Type: User Story
    • Status: Open
    • Priority: Not Evaluated
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
      None

      Description

      E.g., it's nice that we have sliced() now, as a saner alternative to mid(), but that name is suggestive of the possibility to also have slice(). And I'd also like to have sliced() && as an optimisation for when ref-count == 1. Indeed, having worked on Qt's internal QRingBuffer class, I see code that desperately tries to work around the lack of slice():

              if (isShared())
                  return chunk.mid(headOffset, size());
      
              if (headOffset != 0) {
                  char *ptr = chunk.data();
                  ::memmove(ptr, ptr + headOffset, size());
                  tailOffset -= headOffset;
                  headOffset = 0;
              }
      
              chunk.resize(tailOffset);
      

      The middle part is, of course, QByteArray::remove(0, headOffset). So, yes, I can emulate this function by two calls to resize and remove(0, .), but at the cost of two calls (and, as you can see, it's important to get their order right - the above moves too much data).

      So, pretty please, add slice() and sliced() && to all containers that have sliced()?

      Thanks!

        Attachments

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

          Activity

            People

            Assignee:
            cnn Qt Core & Network
            Reporter:
            mmutz Marc Mutz
            PM Owner:
            Vladimir Minenko Vladimir Minenko
            RnD Owner:
            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