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

Unnecessary memcpy done by detach() of QImage::fill()

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 5.6.0
    • Fix Version/s: None
    • Labels:
      None

      Description

      Unnecessary memcpy done by detach() of QImage::fill()

      Profiling our application, we found that when QImage::fill() requires a detach - it unnecessarily performed a memcpy() (deep copy) of the image - unnecessary because fill() is about to overwrite the freshly copied image with new data.

      (For example QByteArray::clear() is smart enough to not copy on detach).

      Note: There is a workaround to avoid the memcpy - but users shouldn't have to be concerned with such thing.

              if (!m_Image.isDetached())
              {
                  // avoid the unnecessary deep copy in detach because we are about to fill anyway.
                  m_Image = QImage(m_Image.width(), m_Image.height(), m_Image.format());
              }
              m_Image.fill(0);
      

        Attachments

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

          Activity

            People

            Assignee:
            sletta Gunnar Sletta
            Reporter:
            stevenr3 Steve Rossen
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes