Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.6.0
-
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);