Title: [133301] trunk/Source
Revision
133301
Author
tk...@chromium.org
Date
2012-11-02 08:26:53 -0700 (Fri, 02 Nov 2012)

Log Message

Optimize DateTimeFormat::quoteAndAppendLiteral output
https://bugs.webkit.org/show_bug.cgi?id=101040

Reviewed by Kentaro Hara.

Source/WebCore:

In LDML date format pattern, only ASCII alphabet and quote have special
roles. So we don't need to quote the input string if it doesn't contain
them.

No new tests. Updated WebKit/chromium/tests/LocaleWinTest.cpp

* platform/text/DateTimeFormat.cpp:
(WebCore::isASCIIAlphabetOrQuote): A helper to check special characters.
(WebCore::DateTimeFormat::quoteAndAppendLiteral):
Append the input string as is if it has no special character.

Source/WebKit/chromium:

* tests/LocaleWinTest.cpp:
(TEST_F): Update test results.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (133300 => 133301)


--- trunk/Source/WebCore/ChangeLog	2012-11-02 15:22:40 UTC (rev 133300)
+++ trunk/Source/WebCore/ChangeLog	2012-11-02 15:26:53 UTC (rev 133301)
@@ -1,3 +1,21 @@
+2012-11-02  Kent Tamura  <tk...@chromium.org>
+
+        Optimize DateTimeFormat::quoteAndAppendLiteral output
+        https://bugs.webkit.org/show_bug.cgi?id=101040
+
+        Reviewed by Kentaro Hara.
+
+        In LDML date format pattern, only ASCII alphabet and quote have special
+        roles. So we don't need to quote the input string if it doesn't contain
+        them.
+
+        No new tests. Updated WebKit/chromium/tests/LocaleWinTest.cpp
+
+        * platform/text/DateTimeFormat.cpp:
+        (WebCore::isASCIIAlphabetOrQuote): A helper to check special characters.
+        (WebCore::DateTimeFormat::quoteAndAppendLiteral):
+        Append the input string as is if it has no special character.
+
 2012-11-02  Ilya Tikhonovsky  <loi...@chromium.org>
 
         Web Inspector: NMI instrument NodeRareData::Map. It uses ~250k on nytimes.com

Modified: trunk/Source/WebCore/platform/text/DateTimeFormat.cpp (133300 => 133301)


--- trunk/Source/WebCore/platform/text/DateTimeFormat.cpp	2012-11-02 15:22:40 UTC (rev 133300)
+++ trunk/Source/WebCore/platform/text/DateTimeFormat.cpp	2012-11-02 15:26:53 UTC (rev 133301)
@@ -241,10 +241,20 @@
     return false;
 }
 
+static bool isASCIIAlphabetOrQuote(UChar ch)
+{
+    return isASCIIAlpha(ch) || ch == '\'';
+}
+
 void DateTimeFormat::quoteAndAppendLiteral(const String& literal, StringBuilder& buffer)
 {
     if (literal.length() <= 0)
         return;
+
+    if (literal.find(isASCIIAlphabetOrQuote) == notFound) {
+        buffer.append(literal);
+        return;
+    }
     
     if (literal.find('\'') == notFound) {
         buffer.append("'");

Modified: trunk/Source/WebKit/chromium/ChangeLog (133300 => 133301)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-11-02 15:22:40 UTC (rev 133300)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-11-02 15:26:53 UTC (rev 133301)
@@ -1,3 +1,13 @@
+2012-11-02  Kent Tamura  <tk...@chromium.org>
+
+        Optimize DateTimeFormat::quoteAndAppendLiteral output
+        https://bugs.webkit.org/show_bug.cgi?id=101040
+
+        Reviewed by Kentaro Hara.
+
+        * tests/LocaleWinTest.cpp:
+        (TEST_F): Update test results.
+
 2012-11-01  Kent Tamura  <tk...@chromium.org>
 
         Introduce ENABLE_DATE_AND_TIME_INPUT_TYPES, and clarify usage of other related flags

Modified: trunk/Source/WebKit/chromium/tests/LocaleWinTest.cpp (133300 => 133301)


--- trunk/Source/WebKit/chromium/tests/LocaleWinTest.cpp	2012-11-02 15:22:40 UTC (rev 133300)
+++ trunk/Source/WebKit/chromium/tests/LocaleWinTest.cpp	2012-11-02 15:26:53 UTC (rev 133301)
@@ -211,17 +211,17 @@
 #if ENABLE(INPUT_MULTIPLE_FIELDS_UI)
 TEST_F(LocaleWinTest, dateFormat)
 {
-    EXPECT_STREQ("y'-'M'-'d", LocaleWin::dateFormat("y-M-d").utf8().data());
+    EXPECT_STREQ("y-M-d", LocaleWin::dateFormat("y-M-d").utf8().data());
     EXPECT_STREQ("''yy'-'''MM'''-'dd", LocaleWin::dateFormat("''yy-''MM''-dd").utf8().data());
     EXPECT_STREQ("yyyy'-''''-'MMM'''''-'dd", LocaleWin::dateFormat("yyyy-''''-MMM''''-dd").utf8().data());
-    EXPECT_STREQ("yyyy'-'''''MMMM'-'dd", LocaleWin::dateFormat("yyyy-''''MMMM-dd").utf8().data());
+    EXPECT_STREQ("yyyy'-'''''MMMM-dd", LocaleWin::dateFormat("yyyy-''''MMMM-dd").utf8().data());
 }
 
 TEST_F(LocaleWinTest, monthFormat)
 {
-    EXPECT_STREQ("MMMM', 'yyyy", monthFormat(EnglishUS).utf8().data());
-    EXPECT_STREQ("MMMM' 'yyyy", monthFormat(FrenchFR).utf8().data());
-    EXPECT_STREQ("yyyy'\xE5\xB9\xB4'M'\xE6\x9C\x88'", monthFormat(JapaneseJP).utf8().data());
+    EXPECT_STREQ("MMMM, yyyy", monthFormat(EnglishUS).utf8().data());
+    EXPECT_STREQ("MMMM yyyy", monthFormat(FrenchFR).utf8().data());
+    EXPECT_STREQ("yyyy\xE5\xB9\xB4M\xE6\x9C\x88", monthFormat(JapaneseJP).utf8().data());
 }
 
 TEST_F(LocaleWinTest, timeFormat)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to