aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/util.cc6
-rw-r--r--src/libutil/util.hh2
2 files changed, 4 insertions, 4 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 01ab9111f..c1b12e725 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -1273,11 +1273,11 @@ string trim(const string & s, const string & whitespace)
}
-string replaceStrings(const std::string & s,
+string replaceStrings(std::string_view s,
const std::string & from, const std::string & to)
{
- if (from.empty()) return s;
- string res = s;
+ string res(s);
+ if (from.empty()) return res;
size_t pos = 0;
while ((pos = res.find(from, pos)) != std::string::npos) {
res.replace(pos, from.size(), to);
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index cafe93702..117fe86e7 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -383,7 +383,7 @@ string trim(const string & s, const string & whitespace = " \n\r\t");
/* Replace all occurrences of a string inside another string. */
-string replaceStrings(const std::string & s,
+string replaceStrings(std::string_view s,
const std::string & from, const std::string & to);