summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-03-29 07:58:42 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2021-03-29 07:58:42 +0000
commit22c7f99f68de47811c334de669da1b4e35d159bb (patch)
tree6812bfa1041c14b978d302ed3dd3f0b43fe5e69e /searchlib
parentae90624a1574db2be4062fcb0546996abc2be19b (diff)
- No need for _currCreator member, it can be constructed from _currFlags when needed.
- No need for _size meber since we have both start and end of buffer.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/query/querybuilder_test.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp45
-rw-r--r--searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h13
-rw-r--r--searchlib/src/vespa/searchlib/query/weight.h4
4 files changed, 27 insertions, 37 deletions
diff --git a/searchlib/src/tests/query/querybuilder_test.cpp b/searchlib/src/tests/query/querybuilder_test.cpp
index f1207da727d..c170f07f441 100644
--- a/searchlib/src/tests/query/querybuilder_test.cpp
+++ b/searchlib/src/tests/query/querybuilder_test.cpp
@@ -593,7 +593,7 @@ TEST("require that empty intermediate node can be added") {
}
TEST("control size of SimpleQueryStackDumpIterator") {
- EXPECT_EQUAL(160u, sizeof(SimpleQueryStackDumpIterator));
+ EXPECT_EQUAL(152u, sizeof(SimpleQueryStackDumpIterator));
}
TEST("test query parsing error") {
diff --git a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp
index d28c0cf1315..622fee6d5c8 100644
--- a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp
+++ b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp
@@ -10,27 +10,25 @@ using search::query::PredicateQueryTerm;
namespace search {
-SimpleQueryStackDumpIterator::SimpleQueryStackDumpIterator(vespalib::stringref buf) :
- _buf(buf.begin()),
- _bufEnd(buf.end()),
- _bufLen(buf.size()),
- _currPos(_buf),
- _currEnd(_buf),
- _currType(ParseItem::ITEM_UNDEF),
- _currCreator(ParseItem::CREA_ORIG),
- _currWeight(100),
- _currUniqueId(0),
- _currFlags(0),
- _currArity(0),
- _curr_index_name(),
- _curr_term(),
- _scratch(),
- _extraIntArg1(0),
- _extraIntArg2(0),
- _extraIntArg3(0),
- _extraDoubleArg4(0),
- _extraDoubleArg5(0),
- _predicate_query_term()
+SimpleQueryStackDumpIterator::SimpleQueryStackDumpIterator(vespalib::stringref buf)
+ : _buf(buf.begin()),
+ _bufEnd(buf.end()),
+ _currPos(_buf),
+ _currEnd(_buf),
+ _currType(ParseItem::ITEM_UNDEF),
+ _currFlags(0),
+ _currWeight(100),
+ _currUniqueId(0),
+ _currArity(0),
+ _curr_index_name(),
+ _curr_term(),
+ _scratch(),
+ _extraIntArg1(0),
+ _extraIntArg2(0),
+ _extraIntArg3(0),
+ _extraDoubleArg4(0),
+ _extraDoubleArg5(0),
+ _predicate_query_term()
{
}
@@ -123,14 +121,11 @@ SimpleQueryStackDumpIterator::next()
_currUniqueId = 0;
}
if (ParseItem::getFeature_Flags(typefield)) {
- if ((p + sizeof(uint32_t)) > _bufEnd) {
- return false;
- }
+ if ((p + sizeof(uint8_t)) > _bufEnd) return false;
_currFlags = (uint8_t)*p++;
} else {
_currFlags = 0;
}
- _currCreator = ParseItem::GetCreator(_currFlags);
switch (_currType) {
case ParseItem::ITEM_OR:
diff --git a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h
index 287ed62d085..99b1b33f78c 100644
--- a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h
+++ b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h
@@ -18,8 +18,6 @@ private:
const char *_buf;
/** Pointer to just past the input buffer */
const char *_bufEnd;
- /** Total length of the input buffer */
- size_t _bufLen;
/** Pointer to the position of the current item in the buffer */
const char *_currPos;
@@ -27,15 +25,12 @@ private:
const char *_currEnd;
/** The type of the current item */
ParseItem::ItemType _currType;
- ParseItem::ItemCreator _currCreator;
+ /** flags of the current item **/
+ uint8_t _currFlags;
/** Rank weight of current item **/
query::Weight _currWeight;
/** unique id of the current item **/
uint32_t _currUniqueId;
-
- /** flags of the current item **/
- uint32_t _currFlags;
-
/** The arity of the current item */
uint32_t _currArity;
/** The index name (field name) in the current item */
@@ -67,7 +62,7 @@ public:
SimpleQueryStackDumpIterator& operator=(const SimpleQueryStackDumpIterator &) = delete;
~SimpleQueryStackDumpIterator();
- vespalib::stringref getStack() const { return vespalib::stringref(_buf, _bufLen); }
+ vespalib::stringref getStack() const { return vespalib::stringref(_buf, _bufEnd - _buf); }
size_t getPosition() const { return _currPos - _buf; }
/**
@@ -87,7 +82,7 @@ public:
* Get the type of the current item.
* @return the type.
*/
- ParseItem::ItemCreator getCreator() const { return _currCreator; }
+ ParseItem::ItemCreator getCreator() const { return ParseItem::GetCreator(_currFlags); }
/**
* Get the rank weight of the current item.
diff --git a/searchlib/src/vespa/searchlib/query/weight.h b/searchlib/src/vespa/searchlib/query/weight.h
index 51596642cd2..3f0d3b12b99 100644
--- a/searchlib/src/vespa/searchlib/query/weight.h
+++ b/searchlib/src/vespa/searchlib/query/weight.h
@@ -19,7 +19,7 @@ public:
* constructor.
* @param value The initial weight in percent; should be 100 unless a specific value is set.
**/
- explicit Weight(int32_t value) : _weight(value) {}
+ explicit Weight(int32_t value) noexcept : _weight(value) {}
/**
* change the weight value.
@@ -40,7 +40,7 @@ public:
double multiplier() const { return 0.01 * _weight; }
/** compare two weights */
- bool operator== (const Weight& other) const { return _weight == other._weight; }
+ bool operator== (const Weight& other) const noexcept { return _weight == other._weight; }
};
}