summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-03-09 12:50:25 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2021-03-09 12:52:29 +0000
commit979ff012778f100fe8f125d6c1535ef28c059584 (patch)
treec93d3c3d42c2c2cd651c611ed115ae0245e22e98 /vespalib
parent4f826fdf0353af5363e0464c02976787939973a0 (diff)
Convert comparator from being a simple comparator to using an explicit less method.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/tests/datastore/unique_store_dictionary/unique_store_dictionary_test.cpp2
-rw-r--r--vespalib/src/vespa/vespalib/datastore/entry_comparator.h2
-rw-r--r--vespalib/src/vespa/vespalib/datastore/entry_comparator_wrapper.h2
-rw-r--r--vespalib/src/vespa/vespalib/datastore/unique_store_comparator.h2
-rw-r--r--vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.hpp8
-rw-r--r--vespalib/src/vespa/vespalib/datastore/unique_store_string_comparator.h2
6 files changed, 9 insertions, 9 deletions
diff --git a/vespalib/src/tests/datastore/unique_store_dictionary/unique_store_dictionary_test.cpp b/vespalib/src/tests/datastore/unique_store_dictionary/unique_store_dictionary_test.cpp
index 6a9215c3eb9..fc5709072b9 100644
--- a/vespalib/src/tests/datastore/unique_store_dictionary/unique_store_dictionary_test.cpp
+++ b/vespalib/src/tests/datastore/unique_store_dictionary/unique_store_dictionary_test.cpp
@@ -25,7 +25,7 @@ public:
Comparator(uint32_t to_find)
: _to_find(to_find)
{}
- bool operator()(const EntryRef lhs, const EntryRef rhs) const override {
+ bool less(const EntryRef lhs, const EntryRef rhs) const override {
return resolve(lhs).ref() < resolve(rhs).ref();
}
};
diff --git a/vespalib/src/vespa/vespalib/datastore/entry_comparator.h b/vespalib/src/vespa/vespalib/datastore/entry_comparator.h
index d0b5b307a9e..027b27bec08 100644
--- a/vespalib/src/vespa/vespalib/datastore/entry_comparator.h
+++ b/vespalib/src/vespa/vespalib/datastore/entry_comparator.h
@@ -19,7 +19,7 @@ public:
/**
* Returns true if the value represented by lhs ref is less than the value represented by rhs ref.
*/
- virtual bool operator()(const EntryRef lhs, const EntryRef rhs) const = 0;
+ virtual bool less(const EntryRef lhs, const EntryRef rhs) const = 0;
};
}
diff --git a/vespalib/src/vespa/vespalib/datastore/entry_comparator_wrapper.h b/vespalib/src/vespa/vespalib/datastore/entry_comparator_wrapper.h
index 199d074b453..2856103b3e1 100644
--- a/vespalib/src/vespa/vespalib/datastore/entry_comparator_wrapper.h
+++ b/vespalib/src/vespa/vespalib/datastore/entry_comparator_wrapper.h
@@ -16,7 +16,7 @@ public:
: _comp(comp)
{ }
bool operator()(const EntryRef &lhs, const EntryRef &rhs) const {
- return _comp(lhs, rhs);
+ return _comp.less(lhs, rhs);
}
};
diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_comparator.h b/vespalib/src/vespa/vespalib/datastore/unique_store_comparator.h
index 3226c4563cc..c99345252d3 100644
--- a/vespalib/src/vespa/vespalib/datastore/unique_store_comparator.h
+++ b/vespalib/src/vespa/vespalib/datastore/unique_store_comparator.h
@@ -93,7 +93,7 @@ public:
{
}
- bool operator()(const EntryRef lhs, const EntryRef rhs) const override {
+ bool less(const EntryRef lhs, const EntryRef rhs) const override {
const EntryType &lhsValue = get(lhs);
const EntryType &rhsValue = get(rhs);
return UniqueStoreComparatorHelper<EntryT>::less(lhsValue, rhsValue);
diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.hpp b/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.hpp
index 8ecf71d08c7..6fcf15e69c1 100644
--- a/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.hpp
+++ b/vespalib/src/vespa/vespalib/datastore/unique_store_dictionary.hpp
@@ -29,7 +29,7 @@ UniqueStoreDictionary<DictionaryT, ParentT>::
ReadSnapshotImpl::count(const EntryComparator& comp) const
{
auto itr = _frozen_view.lowerBound(EntryRef(), comp);
- if (itr.valid() && !comp(EntryRef(), itr.getKey())) {
+ if (itr.valid() && !comp.less(EntryRef(), itr.getKey())) {
return 1u;
}
return 0u;
@@ -43,7 +43,7 @@ ReadSnapshotImpl::count_in_range(const EntryComparator& low,
{
auto low_itr = _frozen_view.lowerBound(EntryRef(), low);
auto high_itr = low_itr;
- if (high_itr.valid() && !high(EntryRef(), high_itr.getKey())) {
+ if (high_itr.valid() && !high.less(EntryRef(), high_itr.getKey())) {
high_itr.seekPast(EntryRef(), high);
}
return high_itr - low_itr;
@@ -94,7 +94,7 @@ UniqueStoreDictionary<DictionaryT, ParentT>::add(const EntryComparator &comp,
std::function<EntryRef(void)> insertEntry)
{
auto itr = _dict.lowerBound(EntryRef(), comp);
- if (itr.valid() && !comp(EntryRef(), itr.getKey())) {
+ if (itr.valid() && !comp.less(EntryRef(), itr.getKey())) {
return UniqueStoreAddResult(itr.getKey(), false);
} else {
@@ -109,7 +109,7 @@ EntryRef
UniqueStoreDictionary<DictionaryT, ParentT>::find(const EntryComparator &comp)
{
auto itr = _dict.lowerBound(EntryRef(), comp);
- if (itr.valid() && !comp(EntryRef(), itr.getKey())) {
+ if (itr.valid() && !comp.less(EntryRef(), itr.getKey())) {
return itr.getKey();
} else {
return EntryRef();
diff --git a/vespalib/src/vespa/vespalib/datastore/unique_store_string_comparator.h b/vespalib/src/vespa/vespalib/datastore/unique_store_string_comparator.h
index 140e38dbef1..a3bd1267049 100644
--- a/vespalib/src/vespa/vespalib/datastore/unique_store_string_comparator.h
+++ b/vespalib/src/vespa/vespalib/datastore/unique_store_string_comparator.h
@@ -44,7 +44,7 @@ public:
{
}
- bool operator()(const EntryRef lhs, const EntryRef rhs) const override {
+ bool less(const EntryRef lhs, const EntryRef rhs) const override {
const char *lhs_value = get(lhs);
const char *rhs_value = get(rhs);
return (strcmp(lhs_value, rhs_value) < 0);