Chromium Code Reviews| Index: third_party/WebKit/Source/wtf/text/StringImpl.h |
| diff --git a/third_party/WebKit/Source/wtf/text/StringImpl.h b/third_party/WebKit/Source/wtf/text/StringImpl.h |
| index 161fa19be061c9ad496f7190c45a2f565eda7fc0..850c54ab74e45d896dffa4e3b8c38464a6ebee9e 100644 |
| --- a/third_party/WebKit/Source/wtf/text/StringImpl.h |
| +++ b/third_party/WebKit/Source/wtf/text/StringImpl.h |
| @@ -31,6 +31,7 @@ |
| #include "wtf/WTFExport.h" |
| #include "wtf/text/Unicode.h" |
| #include <limits.h> |
| +#include <string.h> |
| #if OS(MACOSX) |
| typedef const struct __CFString * CFStringRef; |
| @@ -518,8 +519,14 @@ WTF_EXPORT bool equalIgnoringASCIICase(const StringImpl*, const LChar*); |
| WTF_EXPORT int codePointCompareIgnoringASCIICase(const StringImpl*, const LChar*); |
| -template<typename CharacterType> |
| -inline size_t find(const CharacterType* characters, unsigned length, CharacterType matchCharacter, unsigned index = 0) |
| +inline size_t find(const LChar* characters, unsigned length, LChar matchCharacter, unsigned index = 0) |
| +{ |
| + const LChar* found = static_cast<const LChar*>( |
| + memchr(characters + index, matchCharacter, length - index)); |
|
Nico
2016/05/10 17:47:06
what if index > length?
jbroman
2016/05/11 17:19:32
I'd expect that to be an error at the call site (i
|
| + return found ? found - characters : kNotFound; |
| +} |
| + |
| +inline size_t find(const UChar* characters, unsigned length, UChar matchCharacter, unsigned index = 0) |
| { |
| while (index < length) { |
| if (characters[index] == matchCharacter) |
| @@ -541,6 +548,12 @@ inline size_t find(const LChar* characters, unsigned length, UChar matchCharacte |
| return find(characters, length, static_cast<LChar>(matchCharacter), index); |
| } |
| +template <typename CharacterType> |
| +inline size_t find(const CharacterType* characters, unsigned length, char matchCharacter, unsigned index = 0) |
| +{ |
| + return find(characters, length, static_cast<LChar>(matchCharacter), index); |
|
Nico
2016/05/10 17:47:06
why cast matchCharacter to LChar?
jbroman
2016/05/11 17:19:32
To call the actual implementation above. Without t
|
| +} |
| + |
| inline size_t find(const LChar* characters, unsigned length, CharacterMatchFunctionPtr matchFunction, unsigned index = 0) |
| { |
| while (index < length) { |