- Revision
- 114071
- Author
- [email protected]
- Date
- 2012-04-12 19:25:32 -0700 (Thu, 12 Apr 2012)
Log Message
Inline StringImpl::find(UChar, ...)
https://bugs.webkit.org/show_bug.cgi?id=83737
Patch by Benjamin Poulain <[email protected]> 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:
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (114070 => 114071)
--- trunk/Source/WTF/ChangeLog 2012-04-13 02:12:40 UTC (rev 114070)
+++ trunk/Source/WTF/ChangeLog 2012-04-13 02:25:32 UTC (rev 114071)
@@ -1,3 +1,24 @@
+2012-04-12 Benjamin Poulain <[email protected]>
+
+ 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 <[email protected]>
[Qt] Fix WebKit1 build with V8
Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (114070 => 114071)
--- trunk/Source/WTF/wtf/text/StringImpl.cpp 2012-04-13 02:12:40 UTC (rev 114070)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp 2012-04-13 02:25:32 UTC (rev 114071)
@@ -777,13 +777,6 @@
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())
Modified: trunk/Source/WTF/wtf/text/StringImpl.h (114070 => 114071)
--- trunk/Source/WTF/wtf/text/StringImpl.h 2012-04-13 02:12:40 UTC (rev 114070)
+++ trunk/Source/WTF/wtf/text/StringImpl.h 2012-04-13 02:25:32 UTC (rev 114071)
@@ -481,7 +481,7 @@
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); };
@@ -735,6 +735,79 @@
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)
{
Modified: trunk/Source/WTF/wtf/text/WTFString.h (114070 => 114071)
--- trunk/Source/WTF/wtf/text/WTFString.h 2012-04-13 02:12:40 UTC (rev 114070)
+++ trunk/Source/WTF/wtf/text/WTFString.h 2012-04-13 02:25:32 UTC (rev 114071)
@@ -509,72 +509,6 @@
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());