summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-10-18 17:17:47 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-10-18 17:17:47 +0200
commitab9e6166e8c3e5df6c5ee1132324d524e3698505 (patch)
treec69ebca64ee09bf67d5274e93cde91f3dc66ed7a /AK
parent39546303dadbb760af7ec610da72c10856bac52d (diff)
downloadserenity-ab9e6166e8c3e5df6c5ee1132324d524e3698505.zip
AK: Add String::hash()
Diffstat (limited to 'AK')
-rwxr-xr-xAK/String.h15
1 files changed, 12 insertions, 3 deletions
diff --git a/AK/String.h b/AK/String.h
index 718b51cea0..0db5751810 100755
--- a/AK/String.h
+++ b/AK/String.h
@@ -181,6 +181,13 @@ public:
return *this;
}
+ u32 hash() const
+ {
+ if (!m_impl)
+ return 0;
+ return m_impl->hash();
+ }
+
ByteBuffer to_byte_buffer() const;
template<typename BufferType>
@@ -205,7 +212,10 @@ public:
}
#endif
- StringView view() const { return { characters(), length() }; }
+ StringView view() const
+ {
+ return { characters(), length() };
+ }
private:
bool match_helper(const StringView& mask) const;
@@ -234,7 +244,6 @@ struct Traits<String> : public GenericTraits<String> {
struct CaseInsensitiveStringTraits : public AK::Traits<String> {
static unsigned hash(const String& s) { return s.impl() ? s.to_lowercase().impl()->hash() : 0; }
static bool equals(const String& a, const String& b) { return a.to_lowercase() == b.to_lowercase(); }
-
};
inline bool operator<(const char* characters, const String& string)
@@ -271,5 +280,5 @@ inline bool operator<=(const char* characters, const String& string)
}
-using AK::String;
using AK::CaseInsensitiveStringTraits;
+using AK::String;