summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-08-09 20:12:47 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-08-10 14:24:38 +0000
commit70a0bcf50b20c67e96d85d8a43c3da6e66cc145f (patch)
treefe1a9f46ef4659522b214b2bcf4a37f1211a7f2d
parentfaf0824b22f09ab0c959df4bb29e02df82b9afab (diff)
Avoid eating memory on repeated insert.
-rw-r--r--vespalib/src/vespa/vespalib/stllike/hash_set_insert.hpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/vespalib/src/vespa/vespalib/stllike/hash_set_insert.hpp b/vespalib/src/vespa/vespalib/stllike/hash_set_insert.hpp
index 6d5b7ed8b05..77e46bbf9e8 100644
--- a/vespalib/src/vespa/vespalib/stllike/hash_set_insert.hpp
+++ b/vespalib/src/vespa/vespalib/stllike/hash_set_insert.hpp
@@ -9,7 +9,7 @@ namespace vespalib {
template<typename K, typename H, typename EQ, typename M>
template<typename InputIterator>
hash_set<K, H, EQ, M>::hash_set(InputIterator first, InputIterator last)
- : _ht(0)
+ : _ht(last - first)
{
insert(first, last);
}
@@ -18,7 +18,6 @@ template<typename K, typename H, typename EQ, typename M>
template<typename InputIt>
void
hash_set<K, H, EQ, M>::insert(InputIt first, InputIt last) {
- _ht.resize(last - first + capacity());
for (; first < last; first++) {
insert(*first);
}