diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2010-08-31 13:05:28 (GMT) |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2010-09-09 13:49:10 (GMT) |
commit | 5b9479964baa2a8f4b1278a5894ec1dd181e611c (patch) | |
tree | 0bb2ab5e442821c0f39a0428a52b9d2154b43c77 /src | |
parent | fe350ca756df6392b3d0b7840351fccc89f9ef6f (diff) | |
download | Qt-5b9479964baa2a8f4b1278a5894ec1dd181e611c.zip Qt-5b9479964baa2a8f4b1278a5894ec1dd181e611c.tar.gz Qt-5b9479964baa2a8f4b1278a5894ec1dd181e611c.tar.bz2 |
QList::toVector()/QVector::toStdVector()/QVector::fromStdVector(): use reserve()
Reviewed-by: Olivier Goffart
Merge-request: 799
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/tools/qvector.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index b762b8a..2b8d054 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -293,9 +293,9 @@ public: #ifndef QT_NO_STL static inline QVector<T> fromStdVector(const std::vector<T> &vector) - { QVector<T> tmp; qCopy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; } + { QVector<T> tmp; tmp.reserve(vector.size()); qCopy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; } inline std::vector<T> toStdVector() const - { std::vector<T> tmp; qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; } + { std::vector<T> tmp; tmp.reserve(size()); qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; } #endif private: |