http://trac.webkit.org/changeset/106167
https://bugs.webkit.org/show_bug.cgi?id=77264
broke LayoutTests/fast/js/string-capitalization.html
(Requested by msaboff on #webkit).
Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-01-27
* runtime/StringPrototype.cpp:
(JSC::stringProtoFuncToLowerCase):
(JSC::stringProtoFuncToUpperCase):
* wtf/text/StringImpl.cpp:
(WTF::StringImpl::upper):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@106170
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-01-27 Sheriff Bot <webkit.review.bot@gmail.com>
+
+ Unreviewed, rolling out r106167.
+ http://trac.webkit.org/changeset/106167
+ https://bugs.webkit.org/show_bug.cgi?id=77264
+
+ broke LayoutTests/fast/js/string-capitalization.html
+ (Requested by msaboff on #webkit).
+
+ * runtime/StringPrototype.cpp:
+ (JSC::stringProtoFuncToLowerCase):
+ (JSC::stringProtoFuncToUpperCase):
+ * wtf/text/StringImpl.cpp:
+ (WTF::StringImpl::upper):
+
2012-01-27 Filip Pizlo <fpizlo@apple.com>
Build fix for interpreter platforms.
if (!sSize)
return JSValue::encode(sVal);
- StringImpl* ourImpl = s.impl();
+ StringImpl* ourImpl = s.impl();
RefPtr<StringImpl> lower = ourImpl->lower();
if (ourImpl == lower.get())
return JSValue::encode(sVal);
if (!sSize)
return JSValue::encode(sVal);
- StringImpl* ourImpl = s.impl();
- RefPtr<StringImpl> upper = ourImpl->upper();
- if (ourImpl == upper.get())
- return JSValue::encode(sVal);
- return JSValue::encode(jsString(exec, UString(upper.release())));
+ const UChar* sData = s.characters();
+ Vector<UChar> buffer(sSize);
+
+ UChar ored = 0;
+ for (int i = 0; i < sSize; i++) {
+ UChar c = sData[i];
+ ored |= c;
+ buffer[i] = toASCIIUpper(c);
+ }
+ if (!(ored & ~0x7f))
+ return JSValue::encode(jsString(exec, UString::adopt(buffer)));
+
+ bool error;
+ int length = Unicode::toUpper(buffer.data(), sSize, sData, sSize, &error);
+ if (error) {
+ buffer.resize(length);
+ length = Unicode::toUpper(buffer.data(), length, sData, sSize, &error);
+ if (error)
+ return JSValue::encode(sVal);
+ }
+ if (length == sSize) {
+ if (memcmp(buffer.data(), sData, length * sizeof(UChar)) == 0)
+ return JSValue::encode(sVal);
+ } else
+ buffer.resize(length);
+ return JSValue::encode(jsString(exec, UString::adopt(buffer)));
}
EncodedJSValue JSC_HOST_CALL stringProtoFuncLocaleCompare(ExecState* exec)
CRASH();
int32_t length = m_length;
- const UChar* source16;
-
if (is8Bit()) {
LChar* data8;
RefPtr<StringImpl> newImpl = createUninitialized(m_length, data8);
return newImpl.release();
// Do a slower implementation for cases that include non-ASCII Latin-1 characters.
- for (int32_t i = 0; i < length; i++) {
- UChar upper = Unicode::toUpper(m_data8[i]);
- if (UNLIKELY(upper > 0xff)) {
- // Have a character that is 16bit when converted to uppercase.
- source16 = characters();
- goto upconvert;
- }
-
- data8[i] = static_cast<LChar>(upper);
- }
+ for (int32_t i = 0; i < length; i++)
+ data8[i] = static_cast<LChar>(Unicode::toUpper(m_data8[i]));
return newImpl.release();
}
- source16 = m_data16;
-
-upconvert:
UChar* data16;
RefPtr<StringImpl> newImpl = createUninitialized(m_length, data16);
// Do a faster loop for the case where all the characters are ASCII.
UChar ored = 0;
for (int i = 0; i < length; i++) {
- UChar c = source16[i];
+ UChar c = m_data16[i];
ored |= c;
data16[i] = toASCIIUpper(c);
}
// Do a slower implementation for cases that include non-ASCII characters.
bool error;
newImpl = createUninitialized(m_length, data16);
- int32_t realLength = Unicode::toUpper(data16, length, source16, m_length, &error);
+ int32_t realLength = Unicode::toUpper(data16, length, m_data16, m_length, &error);
if (!error && realLength == length)
return newImpl;
newImpl = createUninitialized(realLength, data16);
- Unicode::toUpper(data16, realLength, source16, m_length, &error);
+ Unicode::toUpper(data16, realLength, m_data16, m_length, &error);
if (error)
return this;
return newImpl.release();