From 9d8ddbd22b41ea956cba9fcf8d0c3224bee3d4b7 Mon Sep 17 00:00:00 2001 From: Hind Montassif Date: Thu, 15 Jun 2023 18:29:56 +0200 Subject: [PATCH] Use string view instead of const ref to string --- libmamba/include/mamba/core/util_string.hpp | 2 +- libmamba/src/core/util_string.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libmamba/include/mamba/core/util_string.hpp b/libmamba/include/mamba/core/util_string.hpp index 32e46b86e0..47deb39b87 100644 --- a/libmamba/include/mamba/core/util_string.hpp +++ b/libmamba/include/mamba/core/util_string.hpp @@ -36,7 +36,7 @@ namespace mamba * str1 is considered smaller than (or equal to) str2. * cf. Channels use case. */ - std::string get_common_substr(const std::string& str1, const std::string& str2); + std::string get_common_substr(std::string_view str1, std::string_view str2); /** * Safe non utf-8 wrapping of (see its doc). diff --git a/libmamba/src/core/util_string.cpp b/libmamba/src/core/util_string.cpp index 3fef482830..f0ecc56e24 100644 --- a/libmamba/src/core/util_string.cpp +++ b/libmamba/src/core/util_string.cpp @@ -18,9 +18,9 @@ namespace mamba /******************************************************** * Implementation of Channels use case util function * *******************************************************/ - std::string get_common_substr(const std::string& str1, const std::string& str2) + std::string get_common_substr(std::string_view str1, std::string_view str2) { - auto common_str = str1; + std::string common_str(str1); while ((str2.find(common_str) == std::string::npos)) { if (common_str.find('/') != std::string::npos)