From a9348e58cdcbc380fae164d6ca2c4e3d84bfedc3 Mon Sep 17 00:00:00 2001 From: Laurent Perron Date: Mon, 31 Mar 2025 16:15:28 +0200 Subject: [PATCH] stringview --- ortools/init/init.cc | 5 +++-- ortools/init/init.h | 5 +++-- ortools/routing/routing.cc | 2 +- ortools/routing/routing.h | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ortools/init/init.cc b/ortools/init/init.cc index 4813b4a4b9..389b27021a 100644 --- a/ortools/init/init.cc +++ b/ortools/init/init.cc @@ -20,12 +20,13 @@ #include "absl/flags/usage.h" #include "absl/log/globals.h" #include "absl/log/initialize.h" +#include "absl/strings/string_view.h" #include "ortools/gurobi/environment.h" #include "ortools/sat/cp_model_solver.h" #include "ortools/sat/cp_model_solver_helpers.h" namespace operations_research { -void CppBridge::InitLogging(const std::string& usage) { +void CppBridge::InitLogging(absl::string_view usage) { absl::SetProgramUsageMessage(usage); absl::InitializeLog(); } @@ -41,7 +42,7 @@ void CppBridge::SetFlags(const CppFlags& flags) { absl::SetFlag(&FLAGS_cp_model_dump_response, flags.cp_model_dump_response); } -bool CppBridge::LoadGurobiSharedLibrary(const std::string& full_library_path) { +bool CppBridge::LoadGurobiSharedLibrary(absl::string_view full_library_path) { return LoadGurobiDynamicLibrary({full_library_path}).ok(); } diff --git a/ortools/init/init.h b/ortools/init/init.h index 142ecd449e..fe058d64ce 100644 --- a/ortools/init/init.h +++ b/ortools/init/init.h @@ -18,6 +18,7 @@ #include #include +#include "absl/strings/string_view.h" #include "ortools/base/logging.h" #include "ortools/base/version.h" #include "ortools/sat/cp_model_solver_helpers.h" @@ -86,7 +87,7 @@ class CppBridge { * * This must be called once before any other library from OR-Tools are used. */ - static void InitLogging(const std::string& usage); + static void InitLogging(absl::string_view usage); /** * Shutdown the C++ logging layer. @@ -111,7 +112,7 @@ class CppBridge { * You need to pass the full path, including the shared library file. * It returns true if the library was found and correctly loaded. */ - static bool LoadGurobiSharedLibrary(const std::string& full_library_path); + static bool LoadGurobiSharedLibrary(absl::string_view full_library_path); /** * Delete a temporary C++ byte array. diff --git a/ortools/routing/routing.cc b/ortools/routing/routing.cc index 398a8225fe..517c315519 100644 --- a/ortools/routing/routing.cc +++ b/ortools/routing/routing.cc @@ -1086,7 +1086,7 @@ bool RoutingModel::HasDimension(absl::string_view dimension_name) const { } RoutingModel::DimensionIndex RoutingModel::GetDimensionIndex( - const std::string& dimension_name) const { + absl::string_view dimension_name) const { return gtl::FindWithDefault(dimension_name_to_index_, dimension_name, kNoDimension); } diff --git a/ortools/routing/routing.h b/ortools/routing/routing.h index 81c5903962..d2d90b3886 100644 --- a/ortools/routing/routing.h +++ b/ortools/routing/routing.h @@ -2196,7 +2196,7 @@ class OR_DLL RoutingModel { const std::vector& state_dependent_evaluator_indices, int64_t slack_max, bool fix_start_cumul_to_zero, RoutingDimension* dimension); - DimensionIndex GetDimensionIndex(const std::string& dimension_name) const; + DimensionIndex GetDimensionIndex(absl::string_view dimension_name) const; /// Creates global and local cumul optimizers for the dimensions needing them, /// and stores them in the corresponding [local|global]_dimension_optimizers_