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

Unified Diff: Source/platform/graphics/Color.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/animation/TimingFunction.cpp ('k') | Source/platform/mhtml/MHTMLArchive.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/Color.cpp
diff --git a/Source/platform/graphics/Color.cpp b/Source/platform/graphics/Color.cpp
index bd989336d8d8e45c7e518ee03e416b3e9c64e08c..07a471ccce804e040f903b50387932ec2168a479 100644
--- a/Source/platform/graphics/Color.cpp
+++ b/Source/platform/graphics/Color.cpp
@@ -194,19 +194,19 @@ String Color::serializedAsCSSComponentValue() const
result.reserveCapacity(32);
bool colorHasAlpha = hasAlpha();
if (colorHasAlpha)
- result.append("rgba(", 5);
+ result.appendLiteral("rgba(");
else
- result.append("rgb(", 4);
+ result.appendLiteral("rgb(");
result.appendNumber(static_cast<unsigned char>(red()));
- result.append(", ", 2);
+ result.appendLiteral(", ");
result.appendNumber(static_cast<unsigned char>(green()));
- result.append(", ", 2);
+ result.appendLiteral(", ");
result.appendNumber(static_cast<unsigned char>(blue()));
if (colorHasAlpha) {
- result.append(", ", 2);
+ result.appendLiteral(", ");
NumberToStringBuffer buffer;
const char* alphaString = numberToFixedPrecisionString(alpha() / 255.0f, 6, buffer, true);
@@ -231,16 +231,14 @@ String Color::serialized() const
StringBuilder result;
result.reserveCapacity(28);
- const char commaSpace[] = ", ";
- const char rgbaParen[] = "rgba(";
- result.append(rgbaParen, 5);
+ result.appendLiteral("rgba(");
result.appendNumber(red());
- result.append(commaSpace, 2);
+ result.appendLiteral(", ");
result.appendNumber(green());
- result.append(commaSpace, 2);
+ result.appendLiteral(", ");
result.appendNumber(blue());
- result.append(commaSpace, 2);
+ result.appendLiteral(", ");
if (!alpha())
result.append('0');
« no previous file with comments | « Source/platform/animation/TimingFunction.cpp ('k') | Source/platform/mhtml/MHTMLArchive.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698