From 478c8b53094ba08b9de0fdd4a6c607d1372f0cfa Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Mon, 16 Jun 2025 17:55:44 +0200 Subject: [PATCH] cleanup and formatting --- ortools/base/dump_vars.h | 3 ++- ortools/base/dump_vars_test.cc | 3 ++- ortools/linear_solver/model_exporter.cc | 2 +- ortools/linear_solver/xpress_interface.cc | 5 +++-- ortools/linear_solver/xpress_interface_test.cc | 2 +- ortools/math_opt/io/proto_converter.cc | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ortools/base/dump_vars.h b/ortools/base/dump_vars.h index 61e6073084..b2814c2e53 100644 --- a/ortools/base/dump_vars.h +++ b/ortools/base/dump_vars.h @@ -142,7 +142,8 @@ std::ostream& operator<<(std::ostream& os, const ::std::optional& opt) { // needed by graph tests template -std::ostream& operator<<(std::ostream& os, const ::util_intops::StrongVector& vec) { +std::ostream& operator<<(std::ostream& os, + const ::util_intops::StrongVector& vec) { for (U it : vec) { os << ::std::to_string(it) << ','; } diff --git a/ortools/base/dump_vars_test.cc b/ortools/base/dump_vars_test.cc index 2dccc6381d..81b4e5ae8d 100644 --- a/ortools/base/dump_vars_test.cc +++ b/ortools/base/dump_vars_test.cc @@ -137,7 +137,8 @@ TEST(DumpVars, StrongInt) { } TEST(DumpVars, StrongVector) { - ::util_intops::StrongVector<::util_intops::CustomStrongInt, float> vec = {49.3, 3.14}; + ::util_intops::StrongVector<::util_intops::CustomStrongInt, float> vec = { + 49.3, 3.14}; EXPECT_EQ(R"(vec = 49.299999,3.140000,)", ToString(DUMP_VARS(vec))); EXPECT_EQ(R"(vec = 49.299999,3.140000,)", DUMP_VARS(vec).str()); } diff --git a/ortools/linear_solver/model_exporter.cc b/ortools/linear_solver/model_exporter.cc index 51a3727677..3554e1961d 100644 --- a/ortools/linear_solver/model_exporter.cc +++ b/ortools/linear_solver/model_exporter.cc @@ -57,7 +57,7 @@ class LineBreaker { // Returns true if string s will fit on the current line without adding a // carriage return. - bool WillFit(const std::string& s) { + bool WillFit(absl::string_view s) { return line_size_ + static_cast(s.size()) < max_line_size_; } diff --git a/ortools/linear_solver/xpress_interface.cc b/ortools/linear_solver/xpress_interface.cc index 0f88bc861c..89f6d4653f 100644 --- a/ortools/linear_solver/xpress_interface.cc +++ b/ortools/linear_solver/xpress_interface.cc @@ -20,8 +20,8 @@ #include #include #include -#include #include +#include #include "absl/strings/numbers.h" #include "absl/strings/str_format.h" @@ -1094,7 +1094,8 @@ void XpressInterface::SetCoefficient(MPConstraint* const constraint, double new_value, double) { InvalidateSolutionSynchronization(); - fixedOrderCoefficientsPerConstraint[constraint->index()][variable->index()] = new_value; + fixedOrderCoefficientsPerConstraint[constraint->index()][variable->index()] = + new_value; // Changing a single coefficient in the matrix is potentially pretty // slow since that coefficient has to be found in the sparse matrix diff --git a/ortools/linear_solver/xpress_interface_test.cc b/ortools/linear_solver/xpress_interface_test.cc index 16925a1e36..35c0cfcaf0 100644 --- a/ortools/linear_solver/xpress_interface_test.cc +++ b/ortools/linear_solver/xpress_interface_test.cc @@ -159,7 +159,7 @@ class XPRSGetter { std::string value(280, '\0'); int valueSize; EXPECT_STATUS(XPRSgetstringattrib(prob(), attrib, &value[0], value.size(), - &valueSize)); + &valueSize)); value.resize(valueSize - 1); return value; } diff --git a/ortools/math_opt/io/proto_converter.cc b/ortools/math_opt/io/proto_converter.cc index 96ffaf24d0..8dd21764c3 100644 --- a/ortools/math_opt/io/proto_converter.cc +++ b/ortools/math_opt/io/proto_converter.cc @@ -317,7 +317,7 @@ MPModelProtoToMathOptModel(const ::operations_research::MPModelProto& model) { for (const MPGeneralConstraintProto& general_constraint : model.general_constraint()) { - const std::string& in_name = general_constraint.name(); + absl::string_view in_name = general_constraint.name(); switch (general_constraint.general_constraint_case()) { case MPGeneralConstraintProto::kQuadraticConstraint: { (*output.mutable_quadratic_constraints())