diff options
author | Marco Bubke <marco.bubke@theqtcompany.com> | 2015-05-06 15:04:22 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> | 2015-05-06 14:23:02 +0000 |
commit | 12f016f9b2d2a28a2bfe0972d0d3cd5cb4dcee87 (patch) | |
tree | 1c54a2d3ec2b413b930d45d73b7ffd37018982a0 | |
parent | fc47d46cc7e43eb69a44e9b07261f671565d8132 (diff) | |
download | qt-creator-12f016f9b2d2a28a2bfe0972d0d3cd5cb4dcee87.tar.gz |
improve utf8 vector join
Change-Id: I4172386312337f1b76aa54d35e0cc541f88de722
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
-rw-r--r-- | src/libs/sqlite/source/utf8stringvector.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/libs/sqlite/source/utf8stringvector.cpp b/src/libs/sqlite/source/utf8stringvector.cpp index ac989aa731..74607ed419 100644 --- a/src/libs/sqlite/source/utf8stringvector.cpp +++ b/src/libs/sqlite/source/utf8stringvector.cpp @@ -71,14 +71,11 @@ Utf8String Utf8StringVector::join(const Utf8String &separator) const { Utf8String joindedString; - int separatorCount = count() - 1; - int byteSizeOfTheJoinedString = totalByteSize() + separator.byteSize() * separatorCount; + joindedString.reserve(totalByteSize() + separator.byteSize() * count()); - joindedString.reserve(byteSizeOfTheJoinedString); - - for (int index = 0; index < count(); index++) { - joindedString.append(at(index)); - if (index < separatorCount) + for (auto position = begin(); position != end(); ++position) { + joindedString.append(*position); + if (std::next(position) != end()) joindedString.append(separator); } @@ -105,7 +102,7 @@ int Utf8StringVector::totalByteSize() const { int totalSize = 0; - foreach (const Utf8String &utf8String, *this) + for (const Utf8String &utf8String : *this) totalSize += utf8String.byteSize(); return totalSize; |