diff --git a/src/xmlpatterns/api/qabstractxmlnodemodel.cpp b/src/xmlpatterns/api/qabstractxmlnodemodel.cpp
index 1a24dcc2acdc5ee27fffce7e07ce0588af2ab54c..177945496cd3ee400580957c5ce9ea75f5e45e49 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);