https://bugs.webkit.org/show_bug.cgi?id=83737
Patch by Benjamin Poulain <bpoulain@apple.com> on 2012-04-12
Reviewed by Geoffrey Garen.
The implementation of StringImpl::find() is a simple branch before invoking one of
two inline functions. The overhead of having a function for StringImpl::find() is significant.
It is better to let the compiler decide if that should be inlined or not.
* wtf/text/StringImpl.cpp:
* wtf/text/StringImpl.h:
(StringImpl):
(WTF::find):
(WTF):
(WTF::reverseFind):
(WTF::StringImpl::find):
* wtf/text/WTFString.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114071
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-04-12 Benjamin Poulain <bpoulain@apple.com>
+
+ Inline StringImpl::find(UChar, ...)
+ https://bugs.webkit.org/show_bug.cgi?id=83737
+
+ Reviewed by Geoffrey Garen.
+
+ The implementation of StringImpl::find() is a simple branch before invoking one of
+ two inline functions. The overhead of having a function for StringImpl::find() is significant.
+
+ It is better to let the compiler decide if that should be inlined or not.
+
+ * wtf/text/StringImpl.cpp:
+ * wtf/text/StringImpl.h:
+ (StringImpl):
+ (WTF::find):
+ (WTF):
+ (WTF::reverseFind):
+ (WTF::StringImpl::find):
+ * wtf/text/WTFString.h:
+
2012-04-12 Balazs Kelemen <kbalazs@webkit.org>
[Qt] Fix WebKit1 build with V8
return umemcasecmp(a, b, length) == 0;
}
-size_t StringImpl::find(UChar c, unsigned start)
-{
- if (is8Bit())
- return WTF::find(characters8(), m_length, c, start);
- return WTF::find(characters16(), m_length, c, start);
-}
-
size_t StringImpl::find(CharacterMatchFunctionPtr matchFunction, unsigned start)
{
if (is8Bit())
template <typename CharType>
ALWAYS_INLINE PassRefPtr<StringImpl> removeCharacters(const CharType* characters, CharacterMatchFunctionPtr);
- WTF_EXPORT_PRIVATE size_t find(UChar, unsigned index = 0);
+ size_t find(UChar character, unsigned start = 0);
WTF_EXPORT_PRIVATE size_t find(CharacterMatchFunctionPtr, unsigned index = 0);
size_t find(const LChar*, unsigned index = 0);
ALWAYS_INLINE size_t find(const char* s, unsigned index = 0) { return find(reinterpret_cast<const LChar*>(s), index); };
WTF_EXPORT_PRIVATE bool equalIgnoringNullity(StringImpl*, StringImpl*);
+inline size_t find(const LChar* characters, unsigned length, LChar matchCharacter, unsigned index = 0)
+{
+ while (index < length) {
+ if (characters[index] == matchCharacter)
+ return index;
+ ++index;
+ }
+ return notFound;
+}
+
+inline size_t find(const UChar* characters, unsigned length, UChar matchCharacter, unsigned index = 0)
+{
+ while (index < length) {
+ if (characters[index] == matchCharacter)
+ return index;
+ ++index;
+ }
+ return notFound;
+}
+
+inline size_t find(const LChar* characters, unsigned length, CharacterMatchFunctionPtr matchFunction, unsigned index = 0)
+{
+ while (index < length) {
+ if (matchFunction(characters[index]))
+ return index;
+ ++index;
+ }
+ return notFound;
+}
+
+inline size_t find(const UChar* characters, unsigned length, CharacterMatchFunctionPtr matchFunction, unsigned index = 0)
+{
+ while (index < length) {
+ if (matchFunction(characters[index]))
+ return index;
+ ++index;
+ }
+ return notFound;
+}
+
+inline size_t reverseFind(const LChar* characters, unsigned length, LChar matchCharacter, unsigned index = UINT_MAX)
+{
+ if (!length)
+ return notFound;
+ if (index >= length)
+ index = length - 1;
+ while (characters[index] != matchCharacter) {
+ if (!index--)
+ return notFound;
+ }
+ return index;
+}
+
+inline size_t reverseFind(const UChar* characters, unsigned length, UChar matchCharacter, unsigned index = UINT_MAX)
+{
+ if (!length)
+ return notFound;
+ if (index >= length)
+ index = length - 1;
+ while (characters[index] != matchCharacter) {
+ if (!index--)
+ return notFound;
+ }
+ return index;
+}
+
+inline size_t StringImpl::find(UChar character, unsigned start)
+{
+ if (is8Bit())
+ return WTF::find(characters8(), m_length, character, start);
+ return WTF::find(characters16(), m_length, character, start);
+}
+
template<size_t inlineCapacity>
bool equalIgnoringNullity(const Vector<UChar, inlineCapacity>& a, StringImpl* b)
{
return codePointCompare(a.impl(), b.impl()) < 0;
}
-inline size_t find(const LChar* characters, unsigned length, LChar matchCharacter, unsigned index = 0)
-{
- while (index < length) {
- if (characters[index] == matchCharacter)
- return index;
- ++index;
- }
- return notFound;
-}
-
-inline size_t find(const UChar* characters, unsigned length, UChar matchCharacter, unsigned index = 0)
-{
- while (index < length) {
- if (characters[index] == matchCharacter)
- return index;
- ++index;
- }
- return notFound;
-}
-
-inline size_t find(const LChar* characters, unsigned length, CharacterMatchFunctionPtr matchFunction, unsigned index = 0)
-{
- while (index < length) {
- if (matchFunction(characters[index]))
- return index;
- ++index;
- }
- return notFound;
-}
-
-inline size_t find(const UChar* characters, unsigned length, CharacterMatchFunctionPtr matchFunction, unsigned index = 0)
-{
- while (index < length) {
- if (matchFunction(characters[index]))
- return index;
- ++index;
- }
- return notFound;
-}
-
-inline size_t reverseFind(const LChar* characters, unsigned length, LChar matchCharacter, unsigned index = UINT_MAX)
-{
- if (!length)
- return notFound;
- if (index >= length)
- index = length - 1;
- while (characters[index] != matchCharacter) {
- if (!index--)
- return notFound;
- }
- return index;
-}
-
-inline size_t reverseFind(const UChar* characters, unsigned length, UChar matchCharacter, unsigned index = UINT_MAX)
-{
- if (!length)
- return notFound;
- if (index >= length)
- index = length - 1;
- while (characters[index] != matchCharacter) {
- if (!index--)
- return notFound;
- }
- return index;
-}
-
inline void append(Vector<UChar>& vector, const String& string)
{
vector.append(string.characters(), string.length());