diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-05-06 21:31:21 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-05-06 21:31:21 +0000 |
commit | e8cb808d5d76ce5848234c1181fa419349f8773a (patch) | |
tree | e117ec5ff056534b6c91f144887b1513d2da5ec7 /searchcommon/src | |
parent | 7b914009b8a607110d7cb4d7f0d405f8e2f8da0b (diff) |
Use a templated helper method to get proper inlining by allowing the correct type
to be known at the right place.
Diffstat (limited to 'searchcommon/src')
-rw-r--r-- | searchcommon/src/vespa/searchcommon/attribute/i_search_context.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h b/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h index be6b8d213d8..f75bf8699c8 100644 --- a/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h +++ b/searchcommon/src/vespa/searchcommon/attribute/i_search_context.h @@ -52,15 +52,17 @@ public: int32_t find(DocId docId, int32_t elementId, int32_t &weight) const { return onFind(docId, elementId, weight); } int32_t find(DocId docId, int32_t elementId) const { return onFind(docId, elementId); } - bool matches(DocId docId, int32_t &weight) const { + template<typename SC> + static bool matches(const SC & sc, DocId docId, int32_t &weight) { weight = 0; int32_t oneWeight(0); - int32_t firstId = find(docId, 0, oneWeight); - for (int32_t id(firstId); id >= 0; id = find(docId, id + 1, oneWeight)) { + int32_t firstId = sc.find(docId, 0, oneWeight); + for (int32_t id(firstId); id >= 0; id = sc.find(docId, id + 1, oneWeight)) { weight += oneWeight; } return firstId >= 0; } + bool matches(DocId docId, int32_t &weight) const { return matches(*this, docId, weight); } bool matches(DocId doc) const { return find(doc, 0) >= 0; } }; |