Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (150041 => 150042)
--- trunk/Source/_javascript_Core/ChangeLog 2013-05-13 21:53:43 UTC (rev 150041)
+++ trunk/Source/_javascript_Core/ChangeLog 2013-05-13 23:11:08 UTC (rev 150042)
@@ -1,3 +1,16 @@
+2013-05-13 Benjamin Poulain <[email protected]>
+
+ Improve stringProtoFuncLastIndexOf for the prefix case
+ https://bugs.webkit.org/show_bug.cgi?id=115952
+
+ Reviewed by Geoffrey Garen.
+
+ * runtime/StringPrototype.cpp:
+ (JSC::stringProtoFuncLastIndexOf):
+ Use the optimized string search when possible.
+
+ On Joseph Pecoraro's tests, this gives a ~30% speed improvement.
+
2013-05-13 Zalan Bujtas <[email protected]>
WebProcess consuming very high CPU on linkedin.com
Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_CoreExports.def (150041 => 150042)
--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_CoreExports.def 2013-05-13 21:53:43 UTC (rev 150041)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_CoreExports.def 2013-05-13 23:11:08 UTC (rev 150042)
@@ -476,6 +476,7 @@
?startProfiling@LegacyProfiler@JSC@@QAEXPAVExecState@2@ABVString@WTF@@@Z
?startSampling@VM@JSC@@QAEXXZ
?startsWith@StringImpl@WTF@@QBE_NPBDI_N@Z
+ ?startsWith@StringImpl@WTF@@QBE_NPBV12@@Z
?startsWith@StringImpl@WTF@@QBE_N_W@Z
?stopProfiling@LegacyProfiler@JSC@@QAE?AV?$PassRefPtr@VProfile@JSC@@@WTF@@PAVExecState@2@ABVString@4@@Z
?stopSampling@VM@JSC@@QAEXXZ
Modified: trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_CoreExportGenerator/_javascript_CoreExports.def.in (150041 => 150042)
--- trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_CoreExportGenerator/_javascript_CoreExports.def.in 2013-05-13 21:53:43 UTC (rev 150041)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcxproj/_javascript_CoreExportGenerator/_javascript_CoreExports.def.in 2013-05-13 23:11:08 UTC (rev 150042)
@@ -474,6 +474,7 @@
?startProfiling@LegacyProfiler@JSC@@QAEXPAVExecState@2@ABVString@WTF@@@Z
?startSampling@VM@JSC@@QAEXXZ
?startsWith@StringImpl@WTF@@QBE_NPBDI_N@Z
+ ?startsWith@StringImpl@WTF@@QBE_NPBV12@@Z
?startsWith@StringImpl@WTF@@QBE_N_W@Z
?stopProfiling@LegacyProfiler@JSC@@QAE?AV?$PassRefPtr@VProfile@JSC@@@WTF@@PAVExecState@2@ABVString@4@@Z
?stopSampling@VM@JSC@@QAEXXZ
Modified: trunk/Source/_javascript_Core/runtime/StringPrototype.cpp (150041 => 150042)
--- trunk/Source/_javascript_Core/runtime/StringPrototype.cpp 2013-05-13 21:53:43 UTC (rev 150041)
+++ trunk/Source/_javascript_Core/runtime/StringPrototype.cpp 2013-05-13 23:11:08 UTC (rev 150042)
@@ -797,7 +797,12 @@
else if (!(dpos <= len)) // true for NaN
dpos = len;
- size_t result = s.reverseFind(u2, static_cast<unsigned>(dpos));
+ size_t result;
+ unsigned startPosition = static_cast<unsigned>(dpos);
+ if (!startPosition)
+ result = s.startsWith(u2) ? 0 : notFound;
+ else
+ result = s.reverseFind(u2, startPosition);
if (result == notFound)
return JSValue::encode(jsNumber(-1));
return JSValue::encode(jsNumber(result));
Modified: trunk/Source/WTF/ChangeLog (150041 => 150042)
--- trunk/Source/WTF/ChangeLog 2013-05-13 21:53:43 UTC (rev 150041)
+++ trunk/Source/WTF/ChangeLog 2013-05-13 23:11:08 UTC (rev 150042)
@@ -1,3 +1,20 @@
+2013-05-13 Benjamin Poulain <[email protected]>
+
+ Improve stringProtoFuncLastIndexOf for the prefix case
+ https://bugs.webkit.org/show_bug.cgi?id=115952
+
+ Reviewed by Geoffrey Garen.
+
+ Add an optimized version of StringImpl::startsWith() for _javascript_Core.
+
+ * wtf/text/StringImpl.cpp:
+ (WTF::StringImpl::startsWith):
+ * wtf/text/StringImpl.h:
+ (StringImpl):
+ (WTF::StringImpl::startsWith):
+ * wtf/text/WTFString.h:
+ (WTF::String::startsWith):
+
2013-05-13 Carlos Garcia Campos <[email protected]>
Unreviewed. Fix Qt Linux MIPS32R2 build after r149879.
Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (150041 => 150042)
--- trunk/Source/WTF/wtf/text/StringImpl.cpp 2013-05-13 21:53:43 UTC (rev 150041)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp 2013-05-13 23:11:08 UTC (rev 150042)
@@ -1252,6 +1252,24 @@
return equalIgnoringCase(stringImpl->characters16() + startOffset, reinterpret_cast<const LChar*>(matchString), matchLength);
}
+bool StringImpl::startsWith(const StringImpl* str) const
+{
+ if (!str)
+ return false;
+
+ if (str->length() > length())
+ return false;
+
+ if (is8Bit()) {
+ if (str->is8Bit())
+ return equal(characters8(), str->characters8(), str->length());
+ return equal(characters8(), str->characters16(), str->length());
+ }
+ if (str->is8Bit())
+ return equal(characters16(), str->characters8(), str->length());
+ return equal(characters16(), str->characters16(), str->length());
+}
+
bool StringImpl::startsWith(UChar character) const
{
return m_length && (*this)[0] == character;
Modified: trunk/Source/WTF/wtf/text/StringImpl.h (150041 => 150042)
--- trunk/Source/WTF/wtf/text/StringImpl.h 2013-05-13 21:53:43 UTC (rev 150041)
+++ trunk/Source/WTF/wtf/text/StringImpl.h 2013-05-13 23:11:08 UTC (rev 150042)
@@ -700,7 +700,8 @@
WTF_EXPORT_STRING_API size_t reverseFind(StringImpl*, unsigned index = UINT_MAX);
WTF_EXPORT_STRING_API size_t reverseFindIgnoringCase(StringImpl*, unsigned index = UINT_MAX);
- bool startsWith(StringImpl* str, bool caseSensitive = true) { return (caseSensitive ? reverseFind(str, 0) : reverseFindIgnoringCase(str, 0)) == 0; }
+ WTF_EXPORT_STRING_API bool startsWith(const StringImpl*) const;
+ bool startsWith(StringImpl* str, bool caseSensitive) { return caseSensitive ? startsWith(str) : (reverseFindIgnoringCase(str, 0) == 0); }
WTF_EXPORT_STRING_API bool startsWith(UChar) const;
WTF_EXPORT_STRING_API bool startsWith(const char*, unsigned matchLength, bool caseSensitive) const;
template<unsigned matchLength>
Modified: trunk/Source/WTF/wtf/text/WTFString.h (150041 => 150042)
--- trunk/Source/WTF/wtf/text/WTFString.h 2013-05-13 21:53:43 UTC (rev 150041)
+++ trunk/Source/WTF/wtf/text/WTFString.h 2013-05-13 23:11:08 UTC (rev 150042)
@@ -289,7 +289,9 @@
bool contains(const LChar* str, bool caseSensitive = true) const { return find(str, 0, caseSensitive) != notFound; }
bool contains(const String& str, bool caseSensitive = true) const { return find(str, 0, caseSensitive) != notFound; }
- bool startsWith(const String& s, bool caseSensitive = true) const
+ bool startsWith(const String& s) const
+ { return m_impl ? m_impl->startsWith(s.impl()) : s.isEmpty(); }
+ bool startsWith(const String& s, bool caseSensitive) const
{ return m_impl ? m_impl->startsWith(s.impl(), caseSensitive) : s.isEmpty(); }
bool startsWith(UChar character) const
{ return m_impl ? m_impl->startsWith(character) : false; }