Changeset 184341 in webkit
- Timestamp:
- May 14, 2015 10:55:38 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r184333 r184341 1 2015-05-14 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Add String literal overloads to equalIgnoringASCIICase() 4 https://bugs.webkit.org/show_bug.cgi?id=145008 5 6 Reviewed by Benjamin Poulain. 7 8 Create an overload for equalIgnoringASCIICase for string literals. 9 10 * wtf/text/StringImpl.h: 11 (WTF::equalIgnoringASCIICase): Use a non-templated helper function. 12 * wtf/text/StringImpl.cpp: 13 (WTF::equalIgnoringASCIICase): Implement it. 14 * wtf/text/StringView.h: 15 (WTF::equalIgnoringASCIICase): Use a non-templated helper function. 16 * wtf/text/StringView.cpp: 17 (WTF::equalIgnoringASCIICase): Implement it. 18 * wtf/text/WTFString.h: 19 (WTF::equalIgnoringASCIICase): Delegate to StringImpl's implementation. 20 1 21 2015-05-14 Žan Doberšek <zdobersek@igalia.com> 2 22 -
trunk/Source/WTF/wtf/text/StringImpl.cpp
r183624 r184341 2076 2076 } 2077 2077 2078 bool equalIgnoringASCIICase(const StringImpl& a, const char* b, unsigned bLength) 2079 { 2080 if (bLength != a.length()) 2081 return false; 2082 2083 if (a.is8Bit()) 2084 return equalIgnoringASCIICase(a.characters8(), b, bLength); 2085 2086 return equalIgnoringASCIICase(a.characters16(), b, bLength); 2087 } 2088 2078 2089 bool equalIgnoringASCIICaseNonNull(const StringImpl* a, const StringImpl* b) 2079 2090 { -
trunk/Source/WTF/wtf/text/StringImpl.h
r183723 r184341 973 973 WTF_EXPORT_STRING_API bool equalIgnoringASCIICase(const StringImpl&, const StringImpl&); 974 974 WTF_EXPORT_STRING_API bool equalIgnoringASCIICase(const StringImpl*, const StringImpl*); 975 WTF_EXPORT_STRING_API bool equalIgnoringASCIICase(const StringImpl& a, const char* b, unsigned bLength); 975 976 WTF_EXPORT_STRING_API bool equalIgnoringASCIICaseNonNull(const StringImpl*, const StringImpl*); 977 978 template<unsigned charactersCount> 979 bool equalIgnoringASCIICase(const StringImpl* a, const char (&b)[charactersCount]) 980 { 981 return a ? equalIgnoringASCIICase(*a, b, charactersCount - 1) : false; 982 } 976 983 977 984 template<typename CharacterType> -
trunk/Source/WTF/wtf/text/StringView.cpp
r181845 r184341 72 72 { 73 73 return ::WTF::endsWithIgnoringASCIICase(*this, suffix); 74 } 75 76 bool equalIgnoringASCIICase(StringView a, const char* b, unsigned bLength) 77 { 78 if (bLength != a.length()) 79 return false; 80 81 if (a.is8Bit()) 82 return equalIgnoringASCIICase(a.characters8(), b, bLength); 83 84 return equalIgnoringASCIICase(a.characters16(), b, bLength); 74 85 } 75 86 -
trunk/Source/WTF/wtf/text/StringView.h
r184037 r184341 157 157 bool equal(StringView, const char*); 158 158 bool equalIgnoringASCIICase(StringView, StringView); 159 WTF_EXPORT_STRING_API bool equalIgnoringASCIICase(StringView a, const char* b, unsigned bLength); 160 template<unsigned charactersCount> 161 bool equalIgnoringASCIICase(StringView a, const char (&b)[charactersCount]) 162 { 163 return equalIgnoringASCIICase(a, b, charactersCount - 1); 164 } 159 165 160 166 inline bool operator==(StringView a, StringView b) { return equal(a, b); } -
trunk/Source/WTF/wtf/text/WTFString.h
r181845 r184341 510 510 511 511 inline bool equalIgnoringASCIICase(const String& a, const String& b) { return equalIgnoringASCIICase(a.impl(), b.impl()); } 512 template<unsigned charactersCount> 513 inline bool equalIgnoringASCIICase(const String& a, const char (&b)[charactersCount]) { return equalIgnoringASCIICase<charactersCount>(a.impl(), b); } 512 514 513 515 inline bool equalPossiblyIgnoringCase(const String& a, const String& b, bool ignoreCase) -
trunk/Tools/ChangeLog
r184331 r184341 1 2015-05-14 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Add String literal overloads to equalIgnoringASCIICase() 4 https://bugs.webkit.org/show_bug.cgi?id=145008 5 6 Reviewed by Benjamin Poulain. 7 8 Test changes to WTF. 9 10 * TestWebKitAPI/Tests/WTF/StringImpl.cpp: 11 (WTF.StringImplEqualIgnoringASCIICaseBasic): Test const char*. 12 (WTF.StringImplEqualIgnoringASCIICaseWithLatin1Characters): Ditto. 13 * TestWebKitAPI/Tests/WTF/StringView.cpp: 14 (WTF.StringViewEqualIgnoringASCIICaseBasic): Ditto. 15 (WTF.StringViewEqualIgnoringASCIICaseWithLatin1Characters): Ditto. 16 1 17 2015-05-14 Youenn Fablet <youenn.fablet@crf.canon.fr> 2 18 -
trunk/Tools/TestWebKitAPI/Tests/WTF/StringImpl.cpp
r182205 r184341 105 105 RefPtr<StringImpl> b = StringImpl::createFromLiteral("ABCDEFG"); 106 106 RefPtr<StringImpl> c = StringImpl::createFromLiteral("abcdefg"); 107 const char d[] = "aBcDeFG"; 107 108 RefPtr<StringImpl> empty = StringImpl::create(reinterpret_cast<const LChar*>("")); 108 109 RefPtr<StringImpl> shorter = StringImpl::createFromLiteral("abcdef"); 110 RefPtr<StringImpl> different = StringImpl::createFromLiteral("abcrefg"); 109 111 110 112 // Identity. … … 112 114 ASSERT_TRUE(equalIgnoringASCIICase(b.get(), b.get())); 113 115 ASSERT_TRUE(equalIgnoringASCIICase(c.get(), c.get())); 116 ASSERT_TRUE(equalIgnoringASCIICase(a.get(), d)); 117 ASSERT_TRUE(equalIgnoringASCIICase(b.get(), d)); 118 ASSERT_TRUE(equalIgnoringASCIICase(c.get(), d)); 114 119 115 120 // Transitivity. … … 125 130 ASSERT_FALSE(equalIgnoringASCIICase(b.get(), shorter.get())); 126 131 ASSERT_FALSE(equalIgnoringASCIICase(c.get(), shorter.get())); 132 ASSERT_FALSE(equalIgnoringASCIICase(a.get(), different.get())); 133 ASSERT_FALSE(equalIgnoringASCIICase(b.get(), different.get())); 134 ASSERT_FALSE(equalIgnoringASCIICase(c.get(), different.get())); 135 ASSERT_FALSE(equalIgnoringASCIICase(empty.get(), d)); 136 ASSERT_FALSE(equalIgnoringASCIICase(shorter.get(), d)); 137 ASSERT_FALSE(equalIgnoringASCIICase(different.get(), d)); 127 138 } 128 139 … … 154 165 RefPtr<StringImpl> c = stringFromUTF8("ABCéEFG"); 155 166 RefPtr<StringImpl> d = stringFromUTF8("abcéefg"); 167 const char e[] = "aBcéeFG"; 156 168 157 169 // Identity. … … 168 180 ASSERT_FALSE(equalIgnoringASCIICase(b.get(), d.get())); 169 181 ASSERT_TRUE(equalIgnoringASCIICase(c.get(), d.get())); 182 ASSERT_FALSE(equalIgnoringASCIICase(a.get(), e)); 183 ASSERT_FALSE(equalIgnoringASCIICase(b.get(), e)); 184 ASSERT_FALSE(equalIgnoringASCIICase(c.get(), e)); 185 ASSERT_FALSE(equalIgnoringASCIICase(d.get(), e)); 170 186 } 171 187 -
trunk/Tools/TestWebKitAPI/Tests/WTF/StringView.cpp
r184037 r184341 148 148 RefPtr<StringImpl> b = StringImpl::createFromLiteral("ABCDEFG"); 149 149 RefPtr<StringImpl> c = StringImpl::createFromLiteral("abcdefg"); 150 const char d[] = "aBcDeFG"; 150 151 RefPtr<StringImpl> empty = StringImpl::create(reinterpret_cast<const LChar*>("")); 151 152 RefPtr<StringImpl> shorter = StringImpl::createFromLiteral("abcdef"); 153 RefPtr<StringImpl> different = StringImpl::createFromLiteral("abcrefg"); 152 154 153 155 StringView stringViewA(*a.get()); … … 156 158 StringView emptyStringView(*empty.get()); 157 159 StringView shorterStringView(*shorter.get()); 160 StringView differentStringView(*different.get()); 158 161 159 162 ASSERT_TRUE(equalIgnoringASCIICase(stringViewA, stringViewB)); 160 163 ASSERT_TRUE(equalIgnoringASCIICase(stringViewB, stringViewC)); 161 164 ASSERT_TRUE(equalIgnoringASCIICase(stringViewB, stringViewC)); 165 ASSERT_TRUE(equalIgnoringASCIICase(stringViewA, d)); 166 ASSERT_TRUE(equalIgnoringASCIICase(stringViewB, d)); 167 ASSERT_TRUE(equalIgnoringASCIICase(stringViewC, d)); 162 168 163 169 // Identity. … … 178 184 ASSERT_FALSE(equalIgnoringASCIICase(stringViewB, shorterStringView)); 179 185 ASSERT_FALSE(equalIgnoringASCIICase(stringViewC, shorterStringView)); 186 ASSERT_FALSE(equalIgnoringASCIICase(stringViewA, differentStringView)); 187 ASSERT_FALSE(equalIgnoringASCIICase(stringViewB, differentStringView)); 188 ASSERT_FALSE(equalIgnoringASCIICase(stringViewC, differentStringView)); 189 ASSERT_FALSE(equalIgnoringASCIICase(emptyStringView, d)); 190 ASSERT_FALSE(equalIgnoringASCIICase(shorterStringView, d)); 191 ASSERT_FALSE(equalIgnoringASCIICase(differentStringView, d)); 180 192 } 181 193 … … 196 208 RefPtr<StringImpl> c = StringImpl::create(reinterpret_cast<const LChar*>("ABCéEFG")); 197 209 RefPtr<StringImpl> d = StringImpl::create(reinterpret_cast<const LChar*>("abcéefg")); 210 const char e[] = "aBcéeFG"; 198 211 StringView stringViewA(*a.get()); 199 212 StringView stringViewB(*b.get()); … … 214 227 ASSERT_FALSE(equalIgnoringASCIICase(stringViewB, stringViewD)); 215 228 ASSERT_TRUE(equalIgnoringASCIICase(stringViewC, stringViewD)); 229 ASSERT_FALSE(equalIgnoringASCIICase(stringViewA, e)); 230 ASSERT_FALSE(equalIgnoringASCIICase(stringViewB, e)); 231 ASSERT_FALSE(equalIgnoringASCIICase(stringViewC, e)); 232 ASSERT_FALSE(equalIgnoringASCIICase(stringViewD, e)); 216 233 } 217 234
Note: See TracChangeset
for help on using the changeset viewer.