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

QString' clear better not to change the capacity.

XMLWordPrintable

    • All
    • 038c1c597 (dev), a151f3461 (6.5), 6c424dbcb (dev), 21a4a2daf (6.7)

      C++'s string (and other C++ stl classes) has clear() and empty() all only change the string's size to 0, not change the string's capacity and not free the memory.

      but qt's QString::clear() will change the capacity and free the memory as below:

      inline void QString::clear(){ if (!isNull()) *this = QString(); }

      this is not efficient when use the same QString many times, so QString::clear() better be the same with the C++'s string.

      thanks!

        For Gerrit Dashboard: QTBUG-60745
        # Subject Branch Project Status CR V

            peppe Giuseppe D'Angelo
            johnff johnff
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: