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

Unified Diff: base/i18n/rtl.cc

Issue 5154009: Cleanup AdjustStringForLocaleDirection() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: further fixes Created 10 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
Index: base/i18n/rtl.cc
diff --git a/base/i18n/rtl.cc b/base/i18n/rtl.cc
index 0881fb785868bc37f2df22e6cd038e3b5786bc69..6a5d29399bf71f545f1cd58084e914e6cb358b25 100644
--- a/base/i18n/rtl.cc
+++ b/base/i18n/rtl.cc
@@ -163,30 +163,27 @@ TextDirection GetFirstStrongCharacterDirection(const std::wstring& text) {
}
#endif
-bool AdjustStringForLocaleDirection(const string16& text,
- string16* localized_text) {
- if (!IsRTL() || text.empty())
+bool AdjustStringForLocaleDirection(string16* text) {
+ if (!IsRTL() || text->empty())
return false;
// Marking the string as LTR if the locale is RTL and the string does not
// contain strong RTL characters. Otherwise, mark the string as RTL.
- *localized_text = text;
- bool has_rtl_chars = StringContainsStrongRTLChars(text);
+ bool has_rtl_chars = StringContainsStrongRTLChars(*text);
if (!has_rtl_chars)
- WrapStringWithLTRFormatting(localized_text);
+ WrapStringWithLTRFormatting(text);
else
- WrapStringWithRTLFormatting(localized_text);
+ WrapStringWithRTLFormatting(text);
return true;
}
#if defined(WCHAR_T_IS_UTF32)
-bool AdjustStringForLocaleDirection(const std::wstring& text,
- std::wstring* localized_text) {
- string16 out;
- if (AdjustStringForLocaleDirection(WideToUTF16(text), &out)) {
+bool AdjustStringForLocaleDirection(std::wstring* text) {
+ string16 temp = WideToUTF16(*text);
+ if (AdjustStringForLocaleDirection(&temp)) {
// We should only touch the output on success.
- *localized_text = UTF16ToWide(out);
+ *text = UTF16ToWide(temp);
return true;
}
return false;

Powered by Google App Engine
This is Rietveld 408576698