From 4a6ce5c34b65df043df36c46ba03a45e36ff0c95 Mon Sep 17 00:00:00 2001
From: Sergio Martins <sergio.martins@kdab.com>
Date: Thu, 28 May 2015 12:34:03 +0100
Subject: [PATCH] Use QVector::reserve()

Change-Id: I86391bf0ede4fb32037b4e98889650e36ef5d279
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
---
 src/xmlpatterns/api/qabstractxmlnodemodel.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/xmlpatterns/api/qabstractxmlnodemodel.cpp b/src/xmlpatterns/api/qabstractxmlnodemodel.cpp
index 1a24dcc2..17794549 100644
--- a/src/xmlpatterns/api/qabstractxmlnodemodel.cpp
+++ b/src/xmlpatterns/api/qabstractxmlnodemodel.cpp
@@ -483,8 +483,9 @@ namespace QPatternist
         virtual QAbstractXmlForwardIterator<QXmlNodeModelIndexIteratorPointer>::Ptr copy() const
         {
             ItVector result;
-
-            for(int i = 0; i < m_list.count(); ++i)
+            const int count = m_list.count();
+            result.reserve(count);
+            for (int i = 0; i < count; ++i)
                 result.append(m_list.at(i)->copy());
 
             return Ptr(new IteratorVector(result));
@@ -501,6 +502,7 @@ static inline QXmlNodeModelIndexIteratorPointer mergeIterators(const QXmlNodeMod
                                                                const QXmlNodeModelIndexIteratorPointer &it2)
 {
     QVector<QXmlNodeModelIndexIteratorPointer> iterators;
+    iterators.reserve(2);
     iterators.append(makeSingletonIterator(node));
     iterators.append(it2);
 
-- 
GitLab