diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-31 11:47:09 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-31 11:47:09 +0100 |
| commit | 027a50abe9f84c833994a35c428d22262a0698b7 (patch) | |
| tree | 3043a05a4ec90b81a9fc5d7ab68a47b86f16ee9d /src | |
| parent | 7ef382f7c1ea2dda38f81d007be29ae49612b95f (diff) | |
| download | qtmaildir-027a50abe9f84c833994a35c428d22262a0698b7.tar.gz qtmaildir-027a50abe9f84c833994a35c428d22262a0698b7.zip | |
fix: keep undo bookkeeping linear on large writes
addChangedMessageIds() ran QStringList::contains per id, quadratic on a
10k-message write, which item 211's archive and item 212's backfill both
produce.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/mainwindow.h | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/mainwindow.h b/src/mainwindow.h index 868964a..45d9288 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -2172,9 +2172,13 @@ public: /// redo of a batch arrives as more than one confirmation. void addChangedMessageIds(const QStringList &ids) { + // A set beside the list, so a 10k-message write is not quadratic + // here (items 211, 212). The list keeps the order for the undo. for (const QString &id : ids) { - if (!m_changedMessageIds.contains(id)) + if (!m_seen.contains(id)) { + m_seen.insert(id); m_changedMessageIds.append(id); + } } } @@ -2183,10 +2187,15 @@ public: protected: /// Cleared before each re-send, so a redo learns what IT moved rather than /// undoing the effect of the run before it. - void forgetChangedMessageIds() { m_changedMessageIds.clear(); } + void forgetChangedMessageIds() + { + m_changedMessageIds.clear(); + m_seen.clear(); + } private: QStringList m_changedMessageIds; + QSet<QString> m_seen; }; /// Undo entry for a tag change over a set of threads. |
