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

Side by Side Diff: Source/platform/text/LocaleWin.cpp

Issue 482753002: Use StringBuilder::appendLiteral() / StringBuilder::append(char) when possible (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/platform/text/DateTimeFormat.cpp ('k') | Source/platform/text/PlatformLocale.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 commitLiteralToken(literalBuffer, converted); 297 commitLiteralToken(literalBuffer, converted);
298 unsigned symbolStart = i; 298 unsigned symbolStart = i;
299 unsigned count = countContinuousLetters(format, i); 299 unsigned count = countContinuousLetters(format, i);
300 i += count - 1; 300 i += count - 1;
301 if (ch == 'h' || ch == 'H' || ch == 'm' || ch == 's' || ch == 'M' || ch == 'y') { 301 if (ch == 'h' || ch == 'H' || ch == 'm' || ch == 's' || ch == 'M' || ch == 'y') {
302 converted.append(format, symbolStart, count); 302 converted.append(format, symbolStart, count);
303 } else if (ch == 'd') { 303 } else if (ch == 'd') {
304 if (count <= 2) 304 if (count <= 2)
305 converted.append(format, symbolStart, count); 305 converted.append(format, symbolStart, count);
306 else if (count == 3) 306 else if (count == 3)
307 converted.append("EEE"); 307 converted.appendLiteral("EEE");
308 else 308 else
309 converted.append("EEEE"); 309 converted.appendLiteral("EEEE");
310 } else if (ch == 'g') { 310 } else if (ch == 'g') {
311 if (count == 1) { 311 if (count == 1) {
312 converted.append('G'); 312 converted.append('G');
313 } else { 313 } else {
314 // gg means imperial era in Windows. 314 // gg means imperial era in Windows.
315 // Just ignore it. 315 // Just ignore it.
316 } 316 }
317 } else if (ch == 't') { 317 } else if (ch == 't') {
318 converted.append('a'); 318 converted.append('a');
319 } else { 319 } else {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 String LocaleWin::shortTimeFormat() 445 String LocaleWin::shortTimeFormat()
446 { 446 {
447 if (!m_timeFormatWithoutSeconds.isNull()) 447 if (!m_timeFormatWithoutSeconds.isNull())
448 return m_timeFormatWithoutSeconds; 448 return m_timeFormatWithoutSeconds;
449 String format = getLocaleInfoString(LOCALE_SSHORTTIME); 449 String format = getLocaleInfoString(LOCALE_SSHORTTIME);
450 // Vista or older Windows doesn't support LOCALE_SSHORTTIME. 450 // Vista or older Windows doesn't support LOCALE_SSHORTTIME.
451 if (format.isEmpty()) { 451 if (format.isEmpty()) {
452 format = getLocaleInfoString(LOCALE_STIMEFORMAT); 452 format = getLocaleInfoString(LOCALE_STIMEFORMAT);
453 StringBuilder builder; 453 StringBuilder builder;
454 builder.append(getLocaleInfoString(LOCALE_STIME)); 454 builder.append(getLocaleInfoString(LOCALE_STIME));
455 builder.append("ss"); 455 builder.appendLiteral("ss");
456 size_t pos = format.reverseFind(builder.toString()); 456 size_t pos = format.reverseFind(builder.toString());
457 if (pos != kNotFound) 457 if (pos != kNotFound)
458 format.remove(pos, builder.length()); 458 format.remove(pos, builder.length());
459 } 459 }
460 m_timeFormatWithoutSeconds = convertWindowsDateTimeFormat(format); 460 m_timeFormatWithoutSeconds = convertWindowsDateTimeFormat(format);
461 return m_timeFormatWithoutSeconds; 461 return m_timeFormatWithoutSeconds;
462 } 462 }
463 463
464 String LocaleWin::dateTimeFormatWithSeconds() 464 String LocaleWin::dateTimeFormatWithSeconds()
465 { 465 {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 case NegativeFormatSignPrefix: // Fall through. 577 case NegativeFormatSignPrefix: // Fall through.
578 default: 578 default:
579 negativePrefix = negativeSign; 579 negativePrefix = negativeSign;
580 break; 580 break;
581 } 581 }
582 m_didInitializeNumberData = true; 582 m_didInitializeNumberData = true;
583 setLocaleData(symbols, emptyString(), emptyString(), negativePrefix, negativ eSuffix); 583 setLocaleData(symbols, emptyString(), emptyString(), negativePrefix, negativ eSuffix);
584 } 584 }
585 585
586 } 586 }
OLDNEW
« no previous file with comments | « Source/platform/text/DateTimeFormat.cpp ('k') | Source/platform/text/PlatformLocale.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698