Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Unified Diff: third_party/WebKit/Source/wtf/text/StringImpl.cpp

Issue 2488763002: Use ICU's case mapping API for Greek uppercasing (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/text/StringImpl.cpp
diff --git a/third_party/WebKit/Source/wtf/text/StringImpl.cpp b/third_party/WebKit/Source/wtf/text/StringImpl.cpp
index 190af7f276ae72205a8c22144b3f67c8689f5cee..c861abfd9da52d9ff4ae314599ceaea2a9b15914 100644
--- a/third_party/WebKit/Source/wtf/text/StringImpl.cpp
+++ b/third_party/WebKit/Source/wtf/text/StringImpl.cpp
@@ -39,8 +39,6 @@
#include "wtf/text/StringToNumber.h"
#include <algorithm>
#include <memory>
-#include <unicode/translit.h>
-#include <unicode/unistr.h>
#ifdef STRING_STATS
#include "wtf/DataLog.h"
@@ -803,7 +801,7 @@ static PassRefPtr<StringImpl> caseConvert(const UChar* source16,
}
PassRefPtr<StringImpl> StringImpl::lower(const AtomicString& localeIdentifier) {
- // Use the more-optimized code path most of the time.
+ // Use the more optimized code path most of the time.
// Only Turkic (tr and az) languages and Lithuanian requires
// locale-specific lowercasing rules. Even though CLDR has el-Lower,
// it's identical to the locale-agnostic lowercasing. Context-dependent
@@ -829,15 +827,14 @@ PassRefPtr<StringImpl> StringImpl::lower(const AtomicString& localeIdentifier) {
PassRefPtr<StringImpl> StringImpl::upper(const AtomicString& localeIdentifier) {
// Use the more-optimized code path most of the time.
- // Only Turkic (tr and az) languages and Greek require locale-specific
- // lowercasing rules.
- icu::UnicodeString transliteratorId;
+ // Only Turkic (tr and az) languages, Greek and Lithuanian require
+ // locale-specific uppercasing rules.
const char* localeForConversion = 0;
if (localeIdMatchesLang(localeIdentifier, "tr") ||
localeIdMatchesLang(localeIdentifier, "az"))
localeForConversion = "tr";
else if (localeIdMatchesLang(localeIdentifier, "el"))
- transliteratorId = UNICODE_STRING_SIMPLE("el-Upper");
+ localeForConversion = "el";
else if (localeIdMatchesLang(localeIdentifier, "lt"))
localeForConversion = "lt";
else
@@ -850,23 +847,7 @@ PassRefPtr<StringImpl> StringImpl::upper(const AtomicString& localeIdentifier) {
RefPtr<StringImpl> upconverted = upconvertedString();
const UChar* source16 = upconverted->characters16();
- if (localeForConversion)
- return caseConvert(source16, length, u_strToUpper, localeForConversion,
- this);
-
- // TODO(jungshik): Cache transliterator if perf penaly warrants it for Greek.
- UErrorCode status = U_ZERO_ERROR;
- std::unique_ptr<icu::Transliterator> translit =
- wrapUnique(icu::Transliterator::createInstance(transliteratorId,
- UTRANS_FORWARD, status));
- if (U_FAILURE(status))
- return upper();
-
- // target will be copy-on-write.
- icu::UnicodeString target(false, source16, length);
- translit->transliterate(target);
-
- return create(target.getBuffer(), target.length());
+ return caseConvert(source16, length, u_strToUpper, localeForConversion, this);
}
PassRefPtr<StringImpl> StringImpl::fill(UChar character) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698