diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-10 09:21:43 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-03-10 10:42:29 +0000 |
commit | 959fd4e9fac8cc23fa37ae94960d0855cb569936 (patch) | |
tree | 5a4496194188d93f6ebb68fcfc65c0e94ce13706 /vespalib | |
parent | 1f2b7657d216d7dfff062c32ffb1cab90d080c94 (diff) |
Prefer std::vector<T, vespalib::allocator_large> over vespalib::Array<T> step 1.
Diffstat (limited to 'vespalib')
4 files changed, 7 insertions, 10 deletions
diff --git a/vespalib/src/vespa/vespalib/stllike/hash_map.hpp b/vespalib/src/vespa/vespalib/stllike/hash_map.hpp index 3ab300c8f1b..5a843d6774c 100644 --- a/vespalib/src/vespa/vespalib/stllike/hash_map.hpp +++ b/vespalib/src/vespa/vespalib/stllike/hash_map.hpp @@ -81,7 +81,6 @@ hash_map<K, V, H, EQ, M>::getMemoryUsed() const vespalib::hashtable<K, std::pair<K,V>, H, E, vespalib::Select1st<std::pair<K,V>>, M>::insertInternal(std::pair<K,V> &&); #define VESPALIB_HASH_MAP_INSTANTIATE_H_E(K, V, H, E) \ - template class vespalib::Array<vespalib::hash_node<std::pair<K,V>>>; \ VESPALIB_HASH_MAP_INSTANTIATE_H_E_M(K, V, H, E, vespalib::hashtable_base::prime_modulator) \ VESPALIB_HASH_MAP_INSTANTIATE_H_E_M(K, V, H, E, vespalib::hashtable_base::and_modulator) diff --git a/vespalib/src/vespa/vespalib/stllike/hash_set.hpp b/vespalib/src/vespa/vespalib/stllike/hash_set.hpp index 2a0617d7d45..332f0c8df69 100644 --- a/vespalib/src/vespa/vespalib/stllike/hash_set.hpp +++ b/vespalib/src/vespa/vespalib/stllike/hash_set.hpp @@ -90,11 +90,9 @@ hash_set<K, H, EQ, M>::insert(K &&value) { #define VESPALIB_HASH_SET_INSTANTIATE(K) \ template class vespalib::hash_set<K>; \ - template class vespalib::hashtable<K, K, vespalib::hash<K>, std::equal_to<>, vespalib::Identity, vespalib::hashtable_base::and_modulator>; \ - template class vespalib::Array<vespalib::hash_node<K>>; + template class vespalib::hashtable<K, K, vespalib::hash<K>, std::equal_to<>, vespalib::Identity, vespalib::hashtable_base::and_modulator>; #define VESPALIB_HASH_SET_INSTANTIATE_H(K, H) \ template class vespalib::hash_set<K, H>; \ - template class vespalib::hashtable<K, K, H, std::equal_to<>, vespalib::Identity, vespalib::hashtable_base::and_modulator>; \ - template class vespalib::Array<vespalib::hash_node<K>>; + template class vespalib::hashtable<K, K, H, std::equal_to<>, vespalib::Identity, vespalib::hashtable_base::and_modulator>; diff --git a/vespalib/src/vespa/vespalib/stllike/hashtable.h b/vespalib/src/vespa/vespalib/stllike/hashtable.h index 4504334a5a8..e8921498a9f 100644 --- a/vespalib/src/vespa/vespalib/stllike/hashtable.h +++ b/vespalib/src/vespa/vespalib/stllike/hashtable.h @@ -1,8 +1,9 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/vespalib/util/array.h> +#include "allocator.h" #include <vespa/vespalib/util/traits.h> +#include <vespa/vespalib/util/alloc.h> #include <algorithm> #include <iterator> @@ -184,7 +185,7 @@ class hashtable : public hashtable_base private: using Node=hash_node<Value>; protected: - using NodeStore = vespalib::Array<Node>; + using NodeStore = std::vector<Node, allocator_large<Node>>; virtual void move(NodeStore && oldStore); public: class const_iterator; diff --git a/vespalib/src/vespa/vespalib/stllike/hashtable.hpp b/vespalib/src/vespa/vespalib/stllike/hashtable.hpp index 52ca9e87247..8289b5a5fd4 100644 --- a/vespalib/src/vespa/vespalib/stllike/hashtable.hpp +++ b/vespalib/src/vespa/vespalib/stllike/hashtable.hpp @@ -2,7 +2,6 @@ #pragma once #include "hashtable.h" -#include <vespa/vespalib/util/array.hpp> #include <algorithm> namespace vespalib { @@ -173,7 +172,7 @@ hashtable<Key, Value, Hash, Equal, KeyExtract, Modulator>::insertInternal(V && n const next_t p(_nodes[h].getNext()); const next_t newIdx(_nodes.size()); _nodes[h].setNext(newIdx); - new (_nodes.push_back_fast()) Node(std::forward<V>(node), p); + _nodes.template emplace_back(std::forward<V>(node), p); _count++; return insert_result(iterator(this, newIdx), true); } else { @@ -197,7 +196,7 @@ hashtable<Key, Value, Hash, Equal, KeyExtract, Modulator>::force_insert(Value && const next_t p(_nodes[h].getNext()); const next_t newIdx(_nodes.size()); _nodes[h].setNext(newIdx); - new (_nodes.push_back_fast()) Node(std::move(value), p); + _nodes.template emplace_back(std::move(value), p); _count++; } else { resize(_nodes.capacity()*2); |