From: Andrew den Exter Date: Wed, 31 Aug 2011 08:03:43 +0000 (+1000) Subject: Compress consecutive removals. X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=d0ed3d21c471088c103859f1e94085b27754a424;p=konrad%2Fqtdeclarative.git Compress consecutive removals. If an applied list of changes has consecutive removals compress them together before applying them to the change set. Change-Id: I75f178a31bbc8480d76be745c62e824125dbd8ba Reviewed-on: http://codereview.qt-project.org/4032 Reviewed-by: Qt Sanity Bot Reviewed-by: Andrew den Exter --- diff --git a/src/declarative/util/qdeclarativechangeset.cpp b/src/declarative/util/qdeclarativechangeset.cpp index a10693f..d941d5e 100644 --- a/src/declarative/util/qdeclarativechangeset.cpp +++ b/src/declarative/util/qdeclarativechangeset.cpp @@ -135,6 +135,22 @@ void QDeclarativeChangeSet::applyRemovals(QVector &removals, QVector::iterator iit = insertions.begin(); for (; rit->moveId != -1 && iit != insertions.end() && iit->moveId != rit->moveId; ++iit) {} + + for (QVector::iterator nrit = rit + 1; nrit != removals.end(); nrit = rit + 1) { + if (nrit->index != rit->index || (rit->moveId == -1) != (nrit->moveId == -1)) + break; + if (nrit->moveId != -1) { + QVector::iterator niit = iit + 1; + if (niit->moveId != nrit->moveId || niit->index != iit->index + iit->count) + break; + niit->index = iit->index; + niit->count += iit->count; + iit = insertions.erase(iit); + } + nrit->count += rit->count; + rit = removals.erase(rit); + } + for (; change != m_changes.end() && change->end() < rit->index; ++change) {} for (; change != m_changes.end() && change->index > rit->end(); ++change) { change->count -= qMin(change->end(), rit->end()) - qMax(change->index, rit->index);