summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2018-11-02 15:11:36 +0100
committerGitHub <noreply@github.com>2018-11-02 15:11:36 +0100
commit6b71ac0c62c27e7db981f378fd763637d41ccce1 (patch)
tree876c83ff8115386f040f547895b0800bf2750138 /document
parentd4572d3347aafa7061ed6104eb56ec5d63e7e9f8 (diff)
parent3a10bfc113278a206fd61ea8ff1e2b1afb04aa16 (diff)
Merge pull request #7540 from vespa-engine/balder/use-templated-find-take-2
Balder/use templated find take 2
Diffstat (limited to 'document')
-rw-r--r--document/src/vespa/document/fieldvalue/mapfieldvalue.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/document/src/vespa/document/fieldvalue/mapfieldvalue.cpp b/document/src/vespa/document/fieldvalue/mapfieldvalue.cpp
index ebd51c82794..9c9c10c1a79 100644
--- a/document/src/vespa/document/fieldvalue/mapfieldvalue.cpp
+++ b/document/src/vespa/document/fieldvalue/mapfieldvalue.cpp
@@ -37,19 +37,26 @@ const MapDataType *verifyMapType(const DataType& type) {
struct Hasher {
Hasher(const MapFieldValue::IArray * keys) : _keys(keys) {}
- uint32_t operator () (uint32_t index) const { return (*_keys)[index].hash(); }
- const MapFieldValue::IArray * _keys;
-};
-
-struct Extract {
- Extract(const MapFieldValue::IArray * keys) : _keys(keys) {}
- const FieldValue & operator () (uint32_t index) const { return (*_keys)[index]; }
+ uint32_t operator () (uint32_t index) const {
+ return (*_keys)[index].hash();
+ }
+ uint32_t operator () (const FieldValue & fv) const {
+ return fv.hash();
+ }
const MapFieldValue::IArray * _keys;
};
struct Equal {
Equal(const MapFieldValue::IArray * keys) : _keys(keys) {}
- bool operator () (uint32_t a, uint32_t b) const { return (*_keys)[a].fastCompare((*_keys)[b]) == 0; }
+ bool operator () (uint32_t a, uint32_t b) const {
+ return (*_keys)[a].fastCompare((*_keys)[b]) == 0;
+ }
+ bool operator () (const FieldValue & a, uint32_t b) const {
+ return a.fastCompare((*_keys)[b]) == 0;
+ }
+ bool operator () (uint32_t a, const FieldValue & b) const {
+ return (*_keys)[a].fastCompare(b) == 0;
+ }
const MapFieldValue::IArray * _keys;
};
@@ -387,8 +394,7 @@ MapFieldValue::findIndex(const FieldValue& key) const
{
if ((size() > 0) && (key.getClass().id() == (*_keys)[0].getClass().id())) {
ensureLookupMap();
- Extract extract(_keys.get());
- auto found = _lookupMap->find<FieldValue, Extract, vespalib::hash<FieldValue>, std::equal_to<FieldValue>>(key, extract);
+ auto found = _lookupMap->find(key);
if (found != _lookupMap->end()) {
uint32_t index = *found;
assert(_present[index]);