Chromium Code Reviews| 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 #include "wtf/text/AtomicString.h" | 7 #include "wtf/text/AtomicString.h" |
| 8 #include "wtf/text/WTFString.h" | 8 #include "wtf/text/WTFString.h" |
| 9 | 9 |
| 10 namespace WTF { | 10 namespace WTF { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 if (a.is8Bit()) { | 56 if (a.is8Bit()) { |
| 57 if (b.is8Bit()) | 57 if (b.is8Bit()) |
| 58 return equal(a.characters8(), b.characters8(), a.length()); | 58 return equal(a.characters8(), b.characters8(), a.length()); |
| 59 return equal(a.characters8(), b.characters16(), a.length()); | 59 return equal(a.characters8(), b.characters16(), a.length()); |
| 60 } | 60 } |
| 61 if (b.is8Bit()) | 61 if (b.is8Bit()) |
| 62 return equal(a.characters16(), b.characters8(), a.length()); | 62 return equal(a.characters16(), b.characters8(), a.length()); |
| 63 return equal(a.characters16(), b.characters16(), a.length()); | 63 return equal(a.characters16(), b.characters16(), a.length()); |
| 64 } | 64 } |
| 65 | 65 |
| 66 | |
| 67 bool equalIgnoringCaseAndNullity(const StringView& a, const StringView& b) | |
| 68 { | |
|
haraken
2016/08/04 09:05:28
Can we add:
DCHECK(!a.isNull());
DCHECK(!b.is
esprehn
2016/08/04 18:30:07
No since the semantics are that you still allow nu
| |
| 69 if (a.length() != b.length()) | |
| 70 return false; | |
| 71 if (a.is8Bit()) { | |
| 72 if (b.is8Bit()) | |
| 73 return equalIgnoringCase(a.characters8(), b.characters8(), a.length( )); | |
| 74 return equalIgnoringCase(a.characters8(), b.characters16(), a.length()); | |
| 75 } | |
| 76 if (b.is8Bit()) | |
| 77 return equalIgnoringCase(a.characters16(), b.characters8(), a.length()); | |
| 78 return equalIgnoringCase(a.characters16(), b.characters16(), a.length()); | |
| 79 } | |
| 80 | |
| 81 bool equalIgnoringCase(const StringView& a, const StringView& b) | |
| 82 { | |
| 83 if (a.isNull() || b.isNull()) | |
| 84 return a.isNull() == b.isNull(); | |
| 85 return equalIgnoringCaseAndNullity(a, b); | |
| 86 } | |
| 87 | |
| 66 bool equalIgnoringASCIICase(const StringView& a, const StringView& b) | 88 bool equalIgnoringASCIICase(const StringView& a, const StringView& b) |
| 67 { | 89 { |
| 68 if (a.isNull() || b.isNull()) | 90 if (a.isNull() || b.isNull()) |
| 69 return a.isNull() == b.isNull(); | 91 return a.isNull() == b.isNull(); |
| 70 if (a.length() != b.length()) | 92 if (a.length() != b.length()) |
| 71 return false; | 93 return false; |
| 72 if (a.is8Bit()) { | 94 if (a.is8Bit()) { |
| 73 if (b.is8Bit()) | 95 if (b.is8Bit()) |
| 74 return equalIgnoringASCIICase(a.characters8(), b.characters8(), a.le ngth()); | 96 return equalIgnoringASCIICase(a.characters8(), b.characters8(), a.le ngth()); |
| 75 return equalIgnoringASCIICase(a.characters8(), b.characters16(), a.lengt h()); | 97 return equalIgnoringASCIICase(a.characters8(), b.characters16(), a.lengt h()); |
| 76 } | 98 } |
| 77 if (b.is8Bit()) | 99 if (b.is8Bit()) |
| 78 return equalIgnoringASCIICase(a.characters16(), b.characters8(), a.lengt h()); | 100 return equalIgnoringASCIICase(a.characters16(), b.characters8(), a.lengt h()); |
| 79 return equalIgnoringASCIICase(a.characters16(), b.characters16(), a.length() ); | 101 return equalIgnoringASCIICase(a.characters16(), b.characters16(), a.length() ); |
| 80 } | 102 } |
| 81 | 103 |
| 82 } // namespace WTF | 104 } // namespace WTF |
| OLD | NEW |