Skip to content

Commit 69e7cba

Browse files
committed
Reserve size for value array
1 parent fe9f72f commit 69e7cba

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/common/winq/extension/ValueArray.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class ValueArray : public std::vector<T> {
4646
template<typename U, typename Enable = typename std::enable_if<std::is_constructible<T, U>::value>::type>
4747
ValueArray(const std::list<U>& others)
4848
{
49+
this->reserve(others.size());
4950
for (const auto& other : others) {
5051
this->emplace_back(other);
5152
}
@@ -54,6 +55,7 @@ class ValueArray : public std::vector<T> {
5455
template<typename U, typename Enable = typename std::enable_if<std::is_constructible<T, U>::value>::type>
5556
ValueArray(const std::initializer_list<U>& others)
5657
{
58+
this->reserve(others.size());
5759
for (const auto& other : others) {
5860
this->emplace_back(other);
5961
}
@@ -62,6 +64,7 @@ class ValueArray : public std::vector<T> {
6264
template<typename U, typename Enable = typename std::enable_if<std::is_constructible<T, U>::value>::type>
6365
ValueArray(const std::vector<U>& others)
6466
{
67+
this->reserve(others.size());
6568
for (const auto& other : others) {
6669
this->emplace_back(other);
6770
}

0 commit comments

Comments
 (0)