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

All implicitly-shared containers: avoid detaching when the size would change (esp. remove)

    XMLWordPrintable

Details

    • detach-remove

    Description

      In almost all remove-like operations, our containers first detach and then do the remove. This is inefficient, because we spend time copying elements we may not want in the final result.

      If *this is shared, then we should not detach. Instead, we should make a new container, and copy only those that would have been kept.

      iow, in pseudo-STL:

      - auto copy = c;
      - remove(copy, x);
      + decltype(c) copy;
      + remove_copy(c, copy, x);
      

      A similar argument can be made for operations that grow the container, like insert().

      Attachments

        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:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes