summaryrefslogtreecommitdiff
path: root/src/mongo/bson/bson_comparator_interface_base.h
diff options
context:
space:
mode:
authorTess Avitabile <tess.avitabile@mongodb.com>2017-08-01 15:32:03 -0400
committerTess Avitabile <tess.avitabile@mongodb.com>2017-08-10 09:40:02 -0400
commitef408a20e6fd71ffc97f3602dd65ef5b03de6a45 (patch)
tree9ab9545f5396fab5580e606b57df74f0e7c5637c /src/mongo/bson/bson_comparator_interface_base.h
parentfad92bef4b8207c5ce392c4402080c0460ccd5ba (diff)
downloadmongo-ef408a20e6fd71ffc97f3602dd65ef5b03de6a45.tar.gz
SERVER-30189 Reduce calls to allocator for large $in expressions
(cherry picked from commit 50a1afafc816097ed57804ff7033dffd85dbe160)
Diffstat (limited to 'src/mongo/bson/bson_comparator_interface_base.h')
-rw-r--r--src/mongo/bson/bson_comparator_interface_base.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mongo/bson/bson_comparator_interface_base.h b/src/mongo/bson/bson_comparator_interface_base.h
index f70bec7b872..29d80916f72 100644
--- a/src/mongo/bson/bson_comparator_interface_base.h
+++ b/src/mongo/bson/bson_comparator_interface_base.h
@@ -28,9 +28,11 @@
#pragma once
+#include <boost/container/flat_set.hpp>
#include <initializer_list>
#include <map>
#include <set>
+#include <vector>
#include "mongo/base/disallow_copying.h"
#include "mongo/base/string_data_comparator_interface.h"
@@ -51,6 +53,9 @@ class BSONComparatorInterfaceBase {
MONGO_DISALLOW_COPYING(BSONComparatorInterfaceBase);
public:
+ BSONComparatorInterfaceBase(BSONComparatorInterfaceBase&& other) = default;
+ BSONComparatorInterfaceBase& operator=(BSONComparatorInterfaceBase&& other) = default;
+
/**
* A deferred comparison between two objects of type T, which can be converted into a boolean
* via the evaluate() method.
@@ -122,6 +127,8 @@ public:
using Set = std::set<T, LessThan>;
+ using FlatSet = boost::container::flat_set<T, LessThan>;
+
using UnorderedSet = stdx::unordered_set<T, Hasher, EqualTo>;
template <typename ValueType>
@@ -207,6 +214,10 @@ protected:
return Set(init, LessThan(this));
}
+ FlatSet makeFlatSet(const std::vector<T>& elements) const {
+ return FlatSet(elements.begin(), elements.end(), LessThan(this));
+ }
+
UnorderedSet makeUnorderedSet(std::initializer_list<T> init = {}) const {
return UnorderedSet(init, 0, Hasher(this), EqualTo(this));
}