Modified: trunk/Source/WTF/ChangeLog (125935 => 125936)
--- trunk/Source/WTF/ChangeLog 2012-08-17 21:29:46 UTC (rev 125935)
+++ trunk/Source/WTF/ChangeLog 2012-08-17 21:36:01 UTC (rev 125936)
@@ -1,3 +1,14 @@
+2012-08-17 Benjamin Poulain <[email protected]>
+
+ Make it easier to append a literal to StringBuilder
+ https://bugs.webkit.org/show_bug.cgi?id=94273
+
+ Reviewed by Kentaro Hara.
+
+ * wtf/text/StringBuilder.h:
+ (WTF::StringBuilder::appendLiteral): Add the method StringBuilder::appendLiteral() for efficiently
+ adding a string literal to the StringBuilder.
+
2012-08-17 Yong Li <[email protected]>
[BlackBerry] Turn on a few macros for jpeg decoding and image interpolation
Modified: trunk/Source/WTF/wtf/text/StringBuilder.h (125935 => 125936)
--- trunk/Source/WTF/wtf/text/StringBuilder.h 2012-08-17 21:29:46 UTC (rev 125935)
+++ trunk/Source/WTF/wtf/text/StringBuilder.h 2012-08-17 21:36:01 UTC (rev 125936)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2009, 2010, 2012 Apple Inc. All rights reserved.
* Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -130,6 +130,9 @@
append(static_cast<LChar>(c));
}
+ template<unsigned charactersCount>
+ ALWAYS_INLINE void appendLiteral(const char (&characters)[charactersCount]) { append(characters, charactersCount - 1); }
+
String toString()
{
shrinkToFit();
Modified: trunk/Source/WebCore/ChangeLog (125935 => 125936)
--- trunk/Source/WebCore/ChangeLog 2012-08-17 21:29:46 UTC (rev 125935)
+++ trunk/Source/WebCore/ChangeLog 2012-08-17 21:36:01 UTC (rev 125936)
@@ -1,5 +1,21 @@
2012-08-17 Benjamin Poulain <[email protected]>
+ Make it easier to append a literal to StringBuilder
+ https://bugs.webkit.org/show_bug.cgi?id=94273
+
+ Reviewed by Kentaro Hara.
+
+ Use StringBuilder::appendLiteral() in MarkupAccumulator instead of computing every
+ value individually.
+
+ * editing/MarkupAccumulator.cpp:
+ (WebCore::MarkupAccumulator::appendComment):
+ (WebCore::MarkupAccumulator::appendXMLDeclaration):
+ (WebCore::MarkupAccumulator::appendDocumentType):
+ (WebCore::MarkupAccumulator::appendCDATASection):
+
+2012-08-17 Benjamin Poulain <[email protected]>
+
Share the StringImpl the CSS property names
https://bugs.webkit.org/show_bug.cgi?id=94187
Modified: trunk/Source/WebCore/editing/MarkupAccumulator.cpp (125935 => 125936)
--- trunk/Source/WebCore/editing/MarkupAccumulator.cpp 2012-08-17 21:29:46 UTC (rev 125935)
+++ trunk/Source/WebCore/editing/MarkupAccumulator.cpp 2012-08-17 21:36:01 UTC (rev 125936)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights reserved.
* Copyright (C) 2009, 2010 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -303,11 +303,9 @@
void MarkupAccumulator::appendComment(StringBuilder& result, const String& comment)
{
// FIXME: Comment content is not escaped, but XMLSerializer (and possibly other callers) should raise an exception if it includes "-->".
- static const char commentBegin[] = "<!--";
- result.append(commentBegin, sizeof(commentBegin) - 1);
+ result.appendLiteral("<!--");
result.append(comment);
- static const char commentEnd[] = "-->";
- result.append(commentEnd, sizeof(commentEnd) - 1);
+ result.appendLiteral("-->");
}
void MarkupAccumulator::appendXMLDeclaration(StringBuilder& result, const Document* document)
@@ -315,29 +313,22 @@
if (!document->hasXMLDeclaration())
return;
- static const char xmlDeclStart[] = "<?xml version=\"";
- result.append(xmlDeclStart, sizeof(xmlDeclStart) - 1);
+ result.appendLiteral("<?xml version=\"");
result.append(document->xmlVersion());
const String& encoding = document->xmlEncoding();
if (!encoding.isEmpty()) {
- static const char xmlEncoding[] = "\" encoding=\"";
- result.append(xmlEncoding, sizeof(xmlEncoding) - 1);
+ result.appendLiteral("\" encoding=\"");
result.append(encoding);
}
if (document->xmlStandaloneStatus() != Document::StandaloneUnspecified) {
- static const char xmlStandalone[] = "\" standalone=\"";
- result.append(xmlStandalone, sizeof(xmlStandalone) - 1);
- if (document->xmlStandalone()) {
- static const char standaloneYes[] = "yes";
- result.append(standaloneYes, sizeof(standaloneYes) - 1);
- } else {
- static const char standaloneNo[] = "no";
- result.append(standaloneNo, sizeof(standaloneNo) - 1);
- }
+ result.appendLiteral("\" standalone=\"");
+ if (document->xmlStandalone())
+ result.appendLiteral("yes");
+ else
+ result.appendLiteral("no");
}
- static const char xmlDeclEnd[] = "\"?>";
- result.append(xmlDeclEnd, sizeof(xmlDeclEnd) - 1);
+ result.appendLiteral("\"?>");
}
void MarkupAccumulator::appendDocumentType(StringBuilder& result, const DocumentType* n)
@@ -345,12 +336,10 @@
if (n->name().isEmpty())
return;
- static const char doctypeString[] = "<!DOCTYPE ";
- result.append(doctypeString, sizeof(doctypeString) - 1);
+ result.appendLiteral("<!DOCTYPE ");
result.append(n->name());
if (!n->publicId().isEmpty()) {
- static const char publicString[] = " PUBLIC \"";
- result.append(publicString, sizeof(publicString) - 1);
+ result.appendLiteral(" PUBLIC \"");
result.append(n->publicId());
result.append('"');
if (!n->systemId().isEmpty()) {
@@ -360,8 +349,7 @@
result.append('"');
}
} else if (!n->systemId().isEmpty()) {
- static const char systemString[] = " SYSTEM \"";
- result.append(systemString, sizeof(systemString) - 1);
+ result.appendLiteral(" SYSTEM \"");
result.append(n->systemId());
result.append('"');
}
@@ -467,11 +455,9 @@
void MarkupAccumulator::appendCDATASection(StringBuilder& result, const String& section)
{
// FIXME: CDATA content is not escaped, but XMLSerializer (and possibly other callers) should raise an exception if it includes "]]>".
- static const char cdataBegin[] = "<![CDATA[";
- result.append(cdataBegin, sizeof(cdataBegin) - 1);
+ result.appendLiteral("<![CDATA[");
result.append(section);
- static const char cdataEnd[] = "]]>";
- result.append(cdataEnd, sizeof(cdataEnd) - 1);
+ result.appendLiteral("]]>");
}
void MarkupAccumulator::appendStartMarkup(StringBuilder& result, const Node* node, Namespaces* namespaces)