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 #include "wtf/text/StringView.h" | 5 #include "wtf/text/StringView.h" |
6 | 6 |
7 namespace WTF { | 7 namespace WTF { |
8 | 8 |
9 StringView::StringView(const UChar* chars, unsigned length) | 9 StringView::StringView(const UChar* chars, unsigned length) |
10 : m_length(length) | 10 : m_length(length) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 if (a.is8Bit()) { | 44 if (a.is8Bit()) { |
45 if (b.is8Bit()) | 45 if (b.is8Bit()) |
46 return equal(a.characters8(), b.characters8(), a.length()); | 46 return equal(a.characters8(), b.characters8(), a.length()); |
47 return equal(a.characters8(), b.characters16(), a.length()); | 47 return equal(a.characters8(), b.characters16(), a.length()); |
48 } | 48 } |
49 if (b.is8Bit()) | 49 if (b.is8Bit()) |
50 return equal(a.characters16(), b.characters8(), a.length()); | 50 return equal(a.characters16(), b.characters8(), a.length()); |
51 return equal(a.characters16(), b.characters16(), a.length()); | 51 return equal(a.characters16(), b.characters16(), a.length()); |
52 } | 52 } |
53 | 53 |
54 bool equalIgnoringASCIICase(StringView a, StringView b) | |
55 { | |
56 if (a.length() != b.length()) | |
57 return false; | |
58 if (a.isEmpty() || b.isEmpty()) | |
Timothy Loh
2016/06/01 05:51:32
How about:
if (a.isEmpty())
return true;
Or
esprehn
2016/06/01 06:19:04
I see that the method in StringImpl.h does accept
| |
59 return a.isEmpty() == b.isEmpty(); | |
60 if (a.is8Bit()) { | |
61 if (b.is8Bit()) | |
62 return equalIgnoringASCIICase(a.characters8(), b.characters8(), a.le ngth()); | |
63 return equalIgnoringASCIICase(a.characters8(), b.characters16(), a.lengt h()); | |
64 } | |
65 if (b.is8Bit()) | |
66 return equalIgnoringASCIICase(a.characters16(), b.characters8(), a.lengt h()); | |
67 return equalIgnoringASCIICase(a.characters16(), b.characters16(), a.length() ); | |
68 } | |
69 | |
54 } // namespace WTF | 70 } // namespace WTF |
OLD | NEW |