Chromium Code Reviews| Index: third_party/WebKit/Source/wtf/text/StringView.h |
| diff --git a/third_party/WebKit/Source/wtf/text/StringView.h b/third_party/WebKit/Source/wtf/text/StringView.h |
| index b595bc980131b5f6f751edbe1a0b01fd9d0d8d93..2be2a969cf97b6f1c3e4094936d64a3ba8af2267 100644 |
| --- a/third_party/WebKit/Source/wtf/text/StringView.h |
| +++ b/third_party/WebKit/Source/wtf/text/StringView.h |
| @@ -70,6 +70,14 @@ public: |
| StringView(const UChar* chars); |
| StringView(const UChar* chars, unsigned length); |
| + // From a byte pointer. |
| + StringView(const void* bytes, unsigned length, bool is8Bit) |
| + : m_length(length) |
| + , m_is8Bit(is8Bit) |
| + { |
| + m_data.bytes = bytes; |
| + } |
| + |
| #if DCHECK_IS_ON() |
| ~StringView(); |
| #endif |
| @@ -83,6 +91,14 @@ public: |
| void clear(); |
| + UChar operator[](unsigned i) const |
| + { |
| + SECURITY_DCHECK(i < length()); |
| + if (is8Bit()) |
| + return characters8()[i]; |
| + return characters16()[i]; |
| + } |
| + |
| const LChar* characters8() const |
| { |
| ASSERT(is8Bit()); |
| @@ -95,6 +111,8 @@ public: |
| return m_data.characters16; |
| } |
| + const void* bytes() const { return m_data.bytes; } |
| + |
| String toString() const; |
| private: |
| @@ -169,6 +187,8 @@ inline void StringView::set(StringImpl& impl, unsigned offset, unsigned length) |
| m_data.characters16 = impl.characters16() + offset; |
| } |
| +WTF_EXPORT bool equalIgnoringASCIICase(StringView a, StringView b); |
|
Timothy Loh
2016/06/01 05:51:32
Maybe const StringView& for consistency with the b
esprehn
2016/06/01 06:19:04
Interestingly base thinks we should pass them by v
|
| + |
| // TODO(esprehn): Can't make this an overload of WTF::equal since that makes |
| // calls to equal() that pass literal strings ambiguous. Figure out if we can |
| // replace all the callers with equalStringView and then rename it to equal(). |