Skip to content

Commit 5ebc2f0

Browse files
committed
Remove const and const ref qualifiers on stringviews
1 parent c3298b4 commit 5ebc2f0

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

include/SemVer.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ namespace OpenShock {
4444
inline bool operator>(const SemVer& other) const { return !(*this <= other); }
4545
inline bool operator>=(const SemVer& other) const { return !(*this < other); }
4646

47-
bool operator==(const std::string_view& other) const;
48-
inline bool operator!=(const std::string_view& other) const { return !(*this == other); }
49-
bool operator<(const std::string_view& other) const;
50-
inline bool operator<=(const std::string_view& other) const { return *this < other || *this == other; }
51-
inline bool operator>(const std::string_view& other) const { return !(*this <= other); }
52-
inline bool operator>=(const std::string_view& other) const { return !(*this < other); }
47+
bool operator==(std::string_view other) const;
48+
inline bool operator!=(std::string_view other) const { return !(*this == other); }
49+
bool operator<(std::string_view other) const;
50+
inline bool operator<=(std::string_view other) const { return *this < other || *this == other; }
51+
inline bool operator>(std::string_view other) const { return !(*this <= other); }
52+
inline bool operator>=(std::string_view other) const { return !(*this < other); }
5353

5454
bool isValid() const;
5555

include/util/StringUtils.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
namespace OpenShock {
1212
bool FormatToString(std::string& out, const char* format, ...);
1313

14-
constexpr std::string_view StringTrimLeft(const std::string_view view) {
14+
constexpr std::string_view StringTrimLeft(std::string_view view) {
1515
if (view.empty()) {
1616
return view;
1717
}
@@ -23,7 +23,7 @@ namespace OpenShock {
2323

2424
return view.substr(pos);
2525
}
26-
constexpr std::string_view StringTrimRight(const std::string_view view) {
26+
constexpr std::string_view StringTrimRight(std::string_view view) {
2727
if (view.empty()) {
2828
return view;
2929
}
@@ -35,14 +35,14 @@ namespace OpenShock {
3535

3636
return view.substr(0, pos + 1);
3737
}
38-
constexpr std::string_view StringTrim(const std::string_view view) {
38+
constexpr std::string_view StringTrim(std::string_view view) {
3939
return StringTrimLeft(StringTrimRight(view));
4040
}
41-
constexpr bool StringStartsWith(const std::string_view view, std::string_view prefix) {
41+
constexpr bool StringStartsWith(std::string_view view, std::string_view prefix) {
4242
return view.size() >= prefix.size() && view.substr(0, prefix.size()) == prefix;
4343
}
4444
template<std::size_t N>
45-
constexpr bool TryStringSplit(const std::string_view view, char delimiter, std::string_view (&out)[N]) {
45+
constexpr bool TryStringSplit(std::string_view view, char delimiter, std::string_view (&out)[N]) {
4646
std::size_t pos = 0;
4747
std::size_t idx = 0;
4848
while (pos < view.size() && idx < N) {
@@ -58,12 +58,12 @@ namespace OpenShock {
5858

5959
return idx == N;
6060
}
61-
std::vector<std::string_view> StringSplit(const std::string_view view, char delimiter, std::size_t maxSplits = std::numeric_limits<std::size_t>::max());
62-
std::vector<std::string_view> StringSplit(const std::string_view view, bool (*predicate)(char delimiter), std::size_t maxSplits = std::numeric_limits<std::size_t>::max());
63-
std::vector<std::string_view> StringSplitNewLines(const std::string_view view, std::size_t maxSplits = std::numeric_limits<std::size_t>::max());
64-
std::vector<std::string_view> StringSplitWhiteSpace(const std::string_view view, std::size_t maxSplits = std::numeric_limits<std::size_t>::max());
61+
std::vector<std::string_view> StringSplit(std::string_view view, char delimiter, std::size_t maxSplits = std::numeric_limits<std::size_t>::max());
62+
std::vector<std::string_view> StringSplit(std::string_view view, bool (*predicate)(char delimiter), std::size_t maxSplits = std::numeric_limits<std::size_t>::max());
63+
std::vector<std::string_view> StringSplitNewLines(std::string_view view, std::size_t maxSplits = std::numeric_limits<std::size_t>::max());
64+
std::vector<std::string_view> StringSplitWhiteSpace(std::string_view view, std::size_t maxSplits = std::numeric_limits<std::size_t>::max());
6565

66-
bool StringIEquals(const std::string_view a, const std::string_view b);
66+
bool StringIEquals(std::string_view a, std::string_view b);
6767

6868
String StringToArduinoString(std::string_view view);
6969
} // namespace OpenShock

src/SemVer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ bool SemVer::operator<(const SemVer& other) const
298298
return build < other.build;
299299
}
300300

301-
bool SemVer::operator==(const std::string_view& other) const
301+
bool SemVer::operator==(std::string_view other) const
302302
{
303303
SemVer otherSemVer;
304304
if (!OpenShock::TryParseSemVer(other, otherSemVer)) {
@@ -308,7 +308,7 @@ bool SemVer::operator==(const std::string_view& other) const
308308
return *this == otherSemVer;
309309
}
310310

311-
bool SemVer::operator<(const std::string_view& other) const
311+
bool SemVer::operator<(std::string_view other) const
312312
{
313313
SemVer otherSemVer;
314314
if (!OpenShock::TryParseSemVer(other, otherSemVer)) {

src/util/StringUtils.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ bool OpenShock::FormatToString(std::string& out, const char* format, ...) {
5858
return true;
5959
}
6060

61-
std::vector<std::string_view> OpenShock::StringSplit(const std::string_view view, char delimiter, std::size_t maxSplits) {
61+
std::vector<std::string_view> OpenShock::StringSplit(std::string_view view, char delimiter, std::size_t maxSplits) {
6262
if (view.empty()) {
6363
return {};
6464
}
@@ -85,7 +85,7 @@ std::vector<std::string_view> OpenShock::StringSplit(const std::string_view view
8585
return result;
8686
}
8787

88-
std::vector<std::string_view> OpenShock::StringSplit(const std::string_view view, bool (*predicate)(char delimiter), std::size_t maxSplits) {
88+
std::vector<std::string_view> OpenShock::StringSplit(std::string_view view, bool (*predicate)(char delimiter), std::size_t maxSplits) {
8989
if (view.empty()) {
9090
return {};
9191
}
@@ -111,19 +111,19 @@ std::vector<std::string_view> OpenShock::StringSplit(const std::string_view view
111111
return result;
112112
}
113113

114-
std::vector<std::string_view> OpenShock::StringSplitNewLines(const std::string_view view, std::size_t maxSplits) {
114+
std::vector<std::string_view> OpenShock::StringSplitNewLines(std::string_view view, std::size_t maxSplits) {
115115
return StringSplit(
116116
view, [](char c) { return c == '\r' || c == '\n'; }, maxSplits
117117
);
118118
}
119119

120-
std::vector<std::string_view> OpenShock::StringSplitWhiteSpace(const std::string_view view, std::size_t maxSplits) {
120+
std::vector<std::string_view> OpenShock::StringSplitWhiteSpace(std::string_view view, std::size_t maxSplits) {
121121
return StringSplit(
122122
view, [](char c) { return isspace(c) != 0; }, maxSplits
123123
);
124124
}
125125

126-
bool OpenShock::StringIEquals(const std::string_view a, const std::string_view b)
126+
bool OpenShock::StringIEquals(std::string_view a, std::string_view b)
127127
{
128128
if (a.size() != b.size()) return false;
129129
return strncasecmp(a.data(), b.data(), a.size()) == 0;

0 commit comments

Comments
 (0)