aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2011-08-31 18:03:43 +1000
committerQt by Nokia <qt-info@nokia.com>2011-09-21 08:23:52 +0200
commitd0ed3d21c471088c103859f1e94085b27754a424 (patch)
treec204752956702d84fb773bddff1c63f182f913c0 /src
parent46bb4a02bd37e402dd7387f1fcc439ca72772671 (diff)
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 <qt_sanity_bot@ovi.com> Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/declarative/util/qdeclarativechangeset.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/declarative/util/qdeclarativechangeset.cpp b/src/declarative/util/qdeclarativechangeset.cpp
index a10693f525..d941d5e842 100644
--- a/src/declarative/util/qdeclarativechangeset.cpp
+++ b/src/declarative/util/qdeclarativechangeset.cpp
@@ -135,6 +135,22 @@ void QDeclarativeChangeSet::applyRemovals(QVector<Remove> &removals, QVector<Ins
QVector<Insert>::iterator iit = insertions.begin();
for (; rit->moveId != -1 && iit != insertions.end() && iit->moveId != rit->moveId; ++iit) {}
+
+ for (QVector<Remove>::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<Insert>::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);