diff options
author | Martijn Otto <martijn.otto@copernica.com> | 2014-10-22 13:32:05 +0200 |
---|---|---|
committer | Martijn Otto <martijn.otto@copernica.com> | 2014-10-22 13:32:05 +0200 |
commit | a2a3b8e78ff00496e391e51d7da0f59659948fba (patch) | |
tree | eafbc1e1e9e5ff715ea9554b8a9153652ed19d23 /include/value.h | |
parent | 4f5d17905cd237ea733fb776f12fc7e05aaebce9 (diff) |
use emplace_back instead of push_back for creating the vector of values
Diffstat (limited to 'include/value.h')
-rw-r--r-- | include/value.h | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/include/value.h b/include/value.h index 2fe940a..77bc0e2 100644 --- a/include/value.h +++ b/include/value.h @@ -457,28 +457,25 @@ public: // allocate a result std::vector<T> result; - + // reserve enough space size_t count = size(); result.reserve(count); - + // and fill the result vector - for (size_t i = 0; i<count; i++) + for (size_t i = 0; i<count; i++) { // check if the index exists if (!contains(i)) continue; - - // get the value object - Value value(get(i)); - - // add it to the vector - result.push_back(value); + + // get the value and add it to the vector + result.emplace_back(get(i)); } - + // done return result; } - + /** * Convert the object to a map with string index and Php::Value value * @return std::map |