summaryrefslogtreecommitdiff
path: root/src/string.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2015-03-30 19:59:08 +0100
committerMaxime Coste <frrrwww@gmail.com>2015-03-30 19:59:08 +0100
commit8761fc34f4dedee89f8cd61be8d08845d09f211e (patch)
treec635b1201830172252befc5124115b928d57e373 /src/string.hh
parent942122837a6b0ed908efb80cb8a2c7a473b2b067 (diff)
Always go through StringView to compare strings
That avoids creating temporary String needlessly
Diffstat (limited to 'src/string.hh')
-rw-r--r--src/string.hh34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/string.hh b/src/string.hh
index b1e51e7e..5e90e98d 100644
--- a/src/string.hh
+++ b/src/string.hh
@@ -20,23 +20,6 @@ class StringOps
public:
using value_type = CharType;
- [[gnu::always_inline]]
- friend bool operator==(const Type& lhs, const Type& rhs)
- {
- return lhs.length() == rhs.length() and
- std::equal(lhs.begin(), lhs.end(), rhs.begin());
- }
-
- [[gnu::always_inline]]
- friend bool operator!=(const Type& lhs, const Type& rhs)
- { return not (lhs == rhs); }
-
- friend bool operator<(const Type& lhs, const Type& rhs)
- {
- return std::lexicographical_compare(lhs.begin(), lhs.end(),
- rhs.begin(), rhs.end());
- }
-
friend inline size_t hash_value(const Type& str)
{
return hash_data(str.data(), (int)str.length());
@@ -220,6 +203,23 @@ inline String operator+(StringView lhs, StringView rhs)
return res;
}
+[[gnu::always_inline]]
+inline bool operator==(const StringView& lhs, const StringView& rhs)
+{
+ return lhs.length() == rhs.length() and
+ std::equal(lhs.begin(), lhs.end(), rhs.begin());
+}
+
+[[gnu::always_inline]]
+inline bool operator!=(const StringView& lhs, const StringView& rhs)
+{ return not (lhs == rhs); }
+
+inline bool operator<(const StringView& lhs, const StringView& rhs)
+{
+ return std::lexicographical_compare(lhs.begin(), lhs.end(),
+ rhs.begin(), rhs.end());
+}
+
Vector<String> split(StringView str, char separator, char escape);
Vector<StringView> split(StringView str, char separator);