summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--document/src/vespa/document/select/parse_utils.cpp2
-rw-r--r--searchlib/src/tests/features/prod_features.cpp9
-rw-r--r--searchlib/src/vespa/searchlib/features/distancetopathfeature.cpp9
3 files changed, 11 insertions, 9 deletions
diff --git a/document/src/vespa/document/select/parse_utils.cpp b/document/src/vespa/document/select/parse_utils.cpp
index 80ee4ef9dfb..2e85f81f089 100644
--- a/document/src/vespa/document/select/parse_utils.cpp
+++ b/document/src/vespa/document/select/parse_utils.cpp
@@ -9,6 +9,8 @@ namespace document::select::util {
// Note: these parsers are all pure, reentrant and without locking.
bool
parse_hex_i64(const char* str, size_t len, int64_t& out) {
+ // Legacy parser parses hex numbers as u64 rather than i64 (then implicitly
+ // converts), so we do the same thing here to avoid change of semantics.
uint64_t val = out;
auto res = std::from_chars(str, str+len, val, 16);
out = val;
diff --git a/searchlib/src/tests/features/prod_features.cpp b/searchlib/src/tests/features/prod_features.cpp
index 81c46558381..4ebc94ccb8b 100644
--- a/searchlib/src/tests/features/prod_features.cpp
+++ b/searchlib/src/tests/features/prod_features.cpp
@@ -828,13 +828,12 @@ struct AirPort {
};
std::pair<int32_t, int32_t> toXY(const AirPort &p) {
- return std::make_pair((int)(p.lng * 1.0e6),
- (int)(p.lat * 1.0e6));
+ return std::make_pair(int(p.lng * 1.0e6), int(p.lat * 1.0e6));
}
GeoLocation toGL(const AirPort &p) {
- int32_t x = (int)(p.lng * 1.0e6);
- int32_t y = (int)(p.lat * 1.0e6);
+ auto x = int(p.lng * 1.0e6);
+ auto y = int(p.lat * 1.0e6);
GeoLocation::Point gp{x, y};
return GeoLocation{gp};
}
@@ -1054,6 +1053,8 @@ Test::testDistanceToPath()
pos.emplace_back(0, 0);
// invalid path
+ assertDistanceToPath(pos, "");
+ assertDistanceToPath(pos, "()");
assertDistanceToPath(pos, "a");
assertDistanceToPath(pos, "(");
assertDistanceToPath(pos, "(a");
diff --git a/searchlib/src/vespa/searchlib/features/distancetopathfeature.cpp b/searchlib/src/vespa/searchlib/features/distancetopathfeature.cpp
index b39e9358a00..3469d776960 100644
--- a/searchlib/src/vespa/searchlib/features/distancetopathfeature.cpp
+++ b/searchlib/src/vespa/searchlib/features/distancetopathfeature.cpp
@@ -49,7 +49,7 @@ DistanceToPathExecutor::execute(uint32_t docId)
double len = std::sqrt(len2);
// For each document location, do
- for (long loc : _intBuf) {
+ for (auto loc : _intBuf) {
int32_t x = 0, y = 0;
vespalib::geo::ZCurve::decode(loc, &x, &y);
@@ -108,7 +108,7 @@ DistanceToPathBlueprint::visitDumpFeatures(const search::fef::IIndexEnvironment
search::fef::Blueprint::UP
DistanceToPathBlueprint::createInstance() const
{
- return Blueprint::UP(new DistanceToPathBlueprint());
+ return std::make_unique<DistanceToPathBlueprint>();
}
bool
@@ -133,11 +133,10 @@ DistanceToPathBlueprint::createExecutor(const search::fef::IQueryEnvironment &en
if (pro.found()) {
vespalib::stringref str = pro.getAt(0);
uint32_t len = str.size();
- if (str[0] == '(' && len > 1 && str[len - 1] == ')') {
+ if ((len > 1) && (str[0] == '(') && (str[len - 1] == ')')) {
str = str.substr(1, len - 1); // remove braces
vespalib::StringTokenizer tokenizer(str);
- len = tokenizer.size() - 1;
- for (uint32_t i = 0; i < len; i += 2) {
+ for (uint32_t i = 0; (i + 2) <= tokenizer.size(); i += 2) {
auto x = util::strToNum<double>(tokenizer[i]);
auto y = util::strToNum<double>(tokenizer[i + 1]);
path.emplace_back(x, y);