Title: [128244] trunk/Source/WebCore
- Revision
- 128244
- Author
- msab...@apple.com
- Date
- 2012-09-11 16:53:46 -0700 (Tue, 11 Sep 2012)
Log Message
jsStringWithCache shouldn't call StringImpl::characters() for single character strings
https://bugs.webkit.org/show_bug.cgi?id=96439
Reviewed by Geoffrey Garen.
Replaced StringImpl->characters()[0] with operator[] access which is character size aware.
Also fixed the other FIXME so we now use SmallStrings to retunr the single character string.
No functional change, so no new tests.
* bindings/js/JSDOMBinding.h:
(WebCore::jsStringWithCache):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (128243 => 128244)
--- trunk/Source/WebCore/ChangeLog 2012-09-11 23:50:50 UTC (rev 128243)
+++ trunk/Source/WebCore/ChangeLog 2012-09-11 23:53:46 UTC (rev 128244)
@@ -1,5 +1,20 @@
2012-09-11 Michael Saboff <msab...@apple.com>
+ jsStringWithCache shouldn't call StringImpl::characters() for single character strings
+ https://bugs.webkit.org/show_bug.cgi?id=96439
+
+ Reviewed by Geoffrey Garen.
+
+ Replaced StringImpl->characters()[0] with operator[] access which is character size aware.
+ Also fixed the other FIXME so we now use SmallStrings to retunr the single character string.
+
+ No functional change, so no new tests.
+
+ * bindings/js/JSDOMBinding.h:
+ (WebCore::jsStringWithCache):
+
+2012-09-11 Michael Saboff <msab...@apple.com>
+
Update ICU header files to more recent version
https://bugs.webkit.org/show_bug.cgi?id=96422
Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (128243 => 128244)
--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h 2012-09-11 23:50:50 UTC (rev 128243)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h 2012-09-11 23:53:46 UTC (rev 128244)
@@ -421,10 +421,13 @@
if (!stringImpl || !stringImpl->length())
return jsEmptyString(exec);
- // FIXME: we shouldn't invoke StringImpl::characters().
- // FIXME: why not just return a SmallStrings when possible?
- if (stringImpl->length() == 1 && stringImpl->characters()[0] <= 0xFF)
- return JSC::jsString(exec, s);
+ if (stringImpl->length() == 1) {
+ UChar singleCharacter = (*stringImpl)[0];
+ if (singleCharacter <= JSC::maxSingleCharacterString) {
+ JSC::JSGlobalData* globalData = &exec->globalData();
+ return globalData->smallStrings.singleCharacterString(globalData, static_cast<unsigned char>(singleCharacter));
+ }
+ }
JSStringCache& stringCache = currentWorld(exec)->m_stringCache;
if (JSC::JSString* string = stringCache.get(stringImpl))
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes