https://bugs.kde.org/show_bug.cgi?id=524780

--- Comment #15 from Ralf Habacker <[email protected]> ---
Git commit 0f90c64ff4a220ea702c9c554d82de2298a3de79 by Ralf Habacker, on behalf
of Michael Spahr.
Committed on 02/11/2026 at 07:35.
Pushed by habacker into branch '5.2'.

Avoid copying a whole pivot grid row for every cell read with Qt6

Since Qt6, QMap::operator[]() const returns a non-const copy of the value
(Qt5 returned a const copy). In the const render methods of PivotTable,
expressions like

    it_row.value()[rowType][column]

therefore call the non-const QList::operator[]() on that temporary copy.
As the copy still shares its data with the grid, this detaches and deep
copies the complete row (one PivotCell per column) just to read a single
cell. renderHTML() and renderCSV() do this for every cell, which makes
the cost quadratic in the number of columns.

Provide a const PivotGridRowSet::operator[]() which returns a const
reference to the row instead. Write access keeps using the inherited
non-const QMap::operator[](). No call sites need to be changed.

Measured with the Flatpak build (Qt 6.11) and the anonymized file
attached to the bug report (weekly Income/Expense report, 31 rows,
871 columns): opening the report went down from ~60 s to ~16 s, and the
share of PivotTable::renderHTML() in the profile from 93 % to 1.7 %.
Most of the remaining time is spent in the QTextBrowser layout, which is
a separate issue.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit c4b52dde38b4f465ffdb3f488a4cee0c5701972a)

M  +7    -0    kmymoney/plugins/views/reports/core/pivotgrid.cpp
M  +15   -0    kmymoney/plugins/views/reports/core/pivotgrid.h

https://invent.kde.org/office/kmymoney/-/commit/0f90c64ff4a220ea702c9c554d82de2298a3de79

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to