stringview

This commit is contained in:
Laurent Perron
2025-03-31 16:15:28 +02:00
parent 6153511356
commit a9348e58cd
4 changed files with 8 additions and 6 deletions

View File

@@ -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();
}

View File

@@ -18,6 +18,7 @@
#include <string>
#include <vector>
#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.

View File

@@ -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);
}

View File

@@ -2196,7 +2196,7 @@ class OR_DLL RoutingModel {
const std::vector<int>& 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_