From fd8d29f8e1ebb51decaccee71aa6119275c11be1 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Mon, 4 Sep 2023 11:40:48 +0000 Subject: Unify and modernize code and layout --- storage/src/vespa/storage/distributor/activecopy.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'storage') diff --git a/storage/src/vespa/storage/distributor/activecopy.cpp b/storage/src/vespa/storage/distributor/activecopy.cpp index 4c35d42a0e7..4659142ddb5 100644 --- a/storage/src/vespa/storage/distributor/activecopy.cpp +++ b/storage/src/vespa/storage/distributor/activecopy.cpp @@ -132,7 +132,7 @@ ActiveCopy::calculate(const Node2Index & idealState, const lib::Distribution& di { IndexList validNodesWithCopy = buildValidNodeIndexList(e); if (validNodesWithCopy.empty()) { - return ActiveList(); + return {}; } std::vector groups; if (distribution.activePerGroup()) { @@ -162,7 +162,7 @@ ActiveCopy::calculate(const Node2Index & idealState, const lib::Distribution& di } result.emplace_back(*best); } - return ActiveList(std::move(result)); + return {std::move(result)}; } void @@ -170,8 +170,8 @@ ActiveList::print(std::ostream& out, bool verbose, const std::string& indent) co { out << "["; if (verbose) { - for (size_t i=0; i<_v.size(); ++i) { - out << "\n" << indent << " " << _v[i].nodeIndex() << " " << _v[i].getReason(); + for (auto i : _v) { + out << "\n" << indent << " " << i.nodeIndex() << " " << i.getReason(); } if (!_v.empty()) { out << "\n" << indent; -- cgit v1.2.3 From 601af030f40b9b7d270e59fbff68dbf32583fef4 Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Mon, 4 Sep 2023 14:05:35 +0000 Subject: Better naming --- .../src/apps/analyze_onnx_model/analyze_onnx_model.cpp | 18 +++++++++--------- storage/src/vespa/storage/distributor/activecopy.cpp | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'storage') diff --git a/eval/src/apps/analyze_onnx_model/analyze_onnx_model.cpp b/eval/src/apps/analyze_onnx_model/analyze_onnx_model.cpp index 864bc7d095d..03db333d582 100644 --- a/eval/src/apps/analyze_onnx_model/analyze_onnx_model.cpp +++ b/eval/src/apps/analyze_onnx_model/analyze_onnx_model.cpp @@ -68,10 +68,10 @@ size_t convert(const vespalib::string & s) { if (ec != std::errc()) { throw std::runtime_error(fmt("Bad format : '%s' at '%s'", s.c_str(), ptr)); } - if (end != vespalib::string::npos) { - return v * 1024; + if (end == vespalib::string::npos) { + throw std::runtime_error(fmt("Bad format : %s", s.c_str())); } - throw std::runtime_error(fmt("Bad format : %s", s.c_str())); + return v * 1024; } MemoryUsage extract_memory_usage() { @@ -266,17 +266,17 @@ int probe_types() { auto &types = root.setObject("outputs"); Onnx model(params["model"].asString().make_string(), Onnx::Optimize::ENABLE); Onnx::WirePlanner planner; - for (const auto & i : model.inputs()) { - auto spec = params["inputs"][i.name].asString().make_string(); + for (const auto & input : model.inputs()) { + auto spec = params["inputs"][input.name].asString().make_string(); auto input_type = ValueType::from_spec(spec); if (input_type.is_error()) { - if (!params["inputs"][i.name].valid()) { - throw MyError(fmt("missing type for model input '%s'", i.name.c_str())); + if (!params["inputs"][input.name].valid()) { + throw MyError(fmt("missing type for model input '%s'", input.name.c_str())); } else { - throw MyError(fmt("invalid type for model input '%s': '%s'",i.name.c_str(), spec.c_str())); + throw MyError(fmt("invalid type for model input '%s': '%s'",input.name.c_str(), spec.c_str())); } } - bind_input(planner, i, input_type); + bind_input(planner, input, input_type); } planner.prepare_output_types(model); for (const auto &output: model.outputs()) { diff --git a/storage/src/vespa/storage/distributor/activecopy.cpp b/storage/src/vespa/storage/distributor/activecopy.cpp index 4659142ddb5..e9d6d8cca30 100644 --- a/storage/src/vespa/storage/distributor/activecopy.cpp +++ b/storage/src/vespa/storage/distributor/activecopy.cpp @@ -170,8 +170,8 @@ ActiveList::print(std::ostream& out, bool verbose, const std::string& indent) co { out << "["; if (verbose) { - for (auto i : _v) { - out << "\n" << indent << " " << i.nodeIndex() << " " << i.getReason(); + for (const auto & copy : _v) { + out << "\n" << indent << " " << copy.nodeIndex() << " " << copy.getReason(); } if (!_v.empty()) { out << "\n" << indent; -- cgit v1.2.3