| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WTF_StringView_h | 5 #ifndef WTF_StringView_h |
| 6 #define WTF_StringView_h | 6 #define WTF_StringView_h |
| 7 | 7 |
| 8 #include "wtf/Allocator.h" | 8 #include "wtf/Allocator.h" |
| 9 #include "wtf/GetPtr.h" | 9 #include "wtf/GetPtr.h" |
| 10 #if DCHECK_IS_ON() | 10 #if DCHECK_IS_ON() |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 unsigned length) { | 208 unsigned length) { |
| 209 SECURITY_DCHECK(offset + length <= impl.length()); | 209 SECURITY_DCHECK(offset + length <= impl.length()); |
| 210 m_length = length; | 210 m_length = length; |
| 211 m_impl = const_cast<StringImpl*>(&impl); | 211 m_impl = const_cast<StringImpl*>(&impl); |
| 212 if (impl.is8Bit()) | 212 if (impl.is8Bit()) |
| 213 m_characters8 = impl.characters8() + offset; | 213 m_characters8 = impl.characters8() + offset; |
| 214 else | 214 else |
| 215 m_characters16 = impl.characters16() + offset; | 215 m_characters16 = impl.characters16() + offset; |
| 216 } | 216 } |
| 217 | 217 |
| 218 // Unicode aware case insensitive string matching. Non-ASCII characters might |
| 219 // match to ASCII characters. These functions are rarely used to implement web |
| 220 // platform features. |
| 218 WTF_EXPORT bool equalIgnoringCase(const StringView&, const StringView&); | 221 WTF_EXPORT bool equalIgnoringCase(const StringView&, const StringView&); |
| 219 WTF_EXPORT bool equalIgnoringASCIICase(const StringView&, const StringView&); | |
| 220 | |
| 221 WTF_EXPORT bool equalIgnoringCaseAndNullity(const StringView&, | 222 WTF_EXPORT bool equalIgnoringCaseAndNullity(const StringView&, |
| 222 const StringView&); | 223 const StringView&); |
| 223 | 224 |
| 225 WTF_EXPORT bool equalIgnoringASCIICase(const StringView&, const StringView&); |
| 226 |
| 224 // TODO(esprehn): Can't make this an overload of WTF::equal since that makes | 227 // TODO(esprehn): Can't make this an overload of WTF::equal since that makes |
| 225 // calls to equal() that pass literal strings ambiguous. Figure out if we can | 228 // calls to equal() that pass literal strings ambiguous. Figure out if we can |
| 226 // replace all the callers with equalStringView and then rename it to equal(). | 229 // replace all the callers with equalStringView and then rename it to equal(). |
| 227 WTF_EXPORT bool equalStringView(const StringView&, const StringView&); | 230 WTF_EXPORT bool equalStringView(const StringView&, const StringView&); |
| 228 | 231 |
| 229 inline bool operator==(const StringView& a, const StringView& b) { | 232 inline bool operator==(const StringView& a, const StringView& b) { |
| 230 return equalStringView(a, b); | 233 return equalStringView(a, b); |
| 231 } | 234 } |
| 232 | 235 |
| 233 inline bool operator!=(const StringView& a, const StringView& b) { | 236 inline bool operator!=(const StringView& a, const StringView& b) { |
| 234 return !(a == b); | 237 return !(a == b); |
| 235 } | 238 } |
| 236 | 239 |
| 237 } // namespace WTF | 240 } // namespace WTF |
| 238 | 241 |
| 239 using WTF::StringView; | 242 using WTF::StringView; |
| 240 using WTF::equalIgnoringASCIICase; | 243 using WTF::equalIgnoringASCIICase; |
| 241 using WTF::equalIgnoringCase; | 244 using WTF::equalIgnoringCase; |
| 242 | 245 |
| 243 #endif | 246 #endif |
| OLD | NEW |