Changeset 126984 in webkit
- Timestamp:
- Aug 29, 2012, 4:16:48 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r126981 r126984 1 2012-08-29 Adam Barth <abarth@webkit.org> 2 3 Improve string efficiency using StringBuilder and StringOperations 4 https://bugs.webkit.org/show_bug.cgi?id=95304 5 6 Reviewed by Eric Seidel. 7 8 As recommended by http://trac.webkit.org/wiki/EfficientStrings. 9 10 * css/CSSLineBoxContainValue.cpp: 11 (WebCore::CSSLineBoxContainValue::customCssText): 12 * css/CSSPropertySourceData.cpp: 13 (WebCore::CSSPropertySourceData::toString): 14 * css/MediaList.cpp: 15 (WebCore::MediaQuerySet::mediaText): 16 * css/ShadowValue.cpp: 17 (WebCore::ShadowValue::customCssText): 18 * dom/MicroDataItemList.cpp: 19 (WebCore::MicroDataItemList::undefinedItemType): 20 * editing/HTMLInterchange.cpp: 21 (WebCore::convertedSpaceString): 22 1 23 2012-08-29 James Robinson <jamesr@chromium.org> 2 24 -
trunk/Source/WebCore/css/CSSLineBoxContainValue.cpp
r124884 r126984 30 30 #include "MemoryInstrumentation.h" 31 31 #include "PlatformString.h" 32 #include <wtf/text/StringBuilder.h> 32 33 33 34 namespace WebCore { … … 41 42 String CSSLineBoxContainValue::customCssText() const 42 43 { 43 String text("");44 StringBuilder text; 44 45 45 46 if (m_value & LineBoxContainBlock) 46 text += "block";47 text.appendLiteral("block"); 47 48 if (m_value & LineBoxContainInline) { 48 49 if (!text.isEmpty()) 49 text += " ";50 text += "inline";50 text.append(' '); 51 text.appendLiteral("inline"); 51 52 } 52 53 if (m_value & LineBoxContainFont) { 53 54 if (!text.isEmpty()) 54 text += " ";55 text += "font";55 text.append(' '); 56 text.appendLiteral("font"); 56 57 } 57 58 if (m_value & LineBoxContainGlyphs) { 58 59 if (!text.isEmpty()) 59 text += " ";60 text += "glyphs";60 text.append(' '); 61 text.appendLiteral("glyphs"); 61 62 } 62 63 if (m_value & LineBoxContainReplaced) { 63 64 if (!text.isEmpty()) 64 text += " ";65 text += "replaced";65 text.append(' '); 66 text.appendLiteral("replaced"); 66 67 } 67 68 if (m_value & LineBoxContainInlineBox) { 68 69 if (!text.isEmpty()) 69 text += " ";70 text += "inline-box";70 text.append(' '); 71 text.appendLiteral("inline-box"); 71 72 } 72 73 73 return text ;74 return text.toString(); 74 75 } 75 76 -
trunk/Source/WebCore/css/CSSPropertySourceData.cpp
r126968 r126984 39 39 #include "PlatformString.h" 40 40 #include <wtf/StaticConstructors.h> 41 #include <wtf/text/StringBuilder.h> 41 42 #include <wtf/text/StringHash.h> 42 43 … … 94 95 return String(); 95 96 96 String result = name; 97 result += ": "; 98 result += value; 97 StringBuilder result; 98 result.append(name); 99 result.appendLiteral(": "); 100 result.append(value); 99 101 if (important) 100 result += importantSuffix;101 result += ";";102 return result ;102 result.append(importantSuffix); 103 result.append(';'); 104 return result.toString(); 103 105 } 104 106 -
trunk/Source/WebCore/css/MediaList.cpp
r124884 r126984 28 28 #include "MediaQueryExp.h" 29 29 #include "MemoryInstrumentation.h" 30 #include <wtf/text/StringBuilder.h> 30 31 31 32 namespace WebCore { … … 199 200 String MediaQuerySet::mediaText() const 200 201 { 201 String text("");202 StringBuilder text; 202 203 203 204 bool first = true; 204 205 for (size_t i = 0; i < m_queries.size(); ++i) { 205 206 if (!first) 206 text += ", ";207 text.appendLiteral(", "); 207 208 else 208 209 first = false; 209 text += m_queries[i]->cssText();210 } 211 return text ;210 text.append(m_queries[i]->cssText()); 211 } 212 return text.toString(); 212 213 } 213 214 -
trunk/Source/WebCore/css/ShadowValue.cpp
r124884 r126984 24 24 #include "MemoryInstrumentation.h" 25 25 #include "PlatformString.h" 26 #include <wtf/text/StringBuilder.h> 26 27 27 28 namespace WebCore { … … 46 47 String ShadowValue::customCssText() const 47 48 { 48 String text("");49 StringBuilder text; 49 50 50 51 if (color) 51 text += color->cssText();52 text.append(color->cssText()); 52 53 if (x) { 53 54 if (!text.isEmpty()) 54 text += " ";55 text += x->cssText();55 text.append(' '); 56 text.append(x->cssText()); 56 57 } 57 58 if (y) { 58 59 if (!text.isEmpty()) 59 text += " ";60 text += y->cssText();60 text.append(' '); 61 text.append(y->cssText()); 61 62 } 62 63 if (blur) { 63 64 if (!text.isEmpty()) 64 text += " ";65 text += blur->cssText();65 text.append(' '); 66 text.append(blur->cssText()); 66 67 } 67 68 if (spread) { 68 69 if (!text.isEmpty()) 69 text += " ";70 text += spread->cssText();70 text.append(' '); 71 text.append(spread->cssText()); 71 72 } 72 73 if (style) { 73 74 if (!text.isEmpty()) 74 text += " ";75 text += style->cssText();75 text.append(' '); 76 text.append(style->cssText()); 76 77 } 77 78 78 return text ;79 return text.toString(); 79 80 } 80 81 -
trunk/Source/WebCore/dom/MicroDataItemList.cpp
r126968 r126984 41 41 const String& MicroDataItemList::undefinedItemType() 42 42 { 43 DEFINE_STATIC_LOCAL(String, undefinedItemTypeString, ("")); 44 // FIXME: Why not just return emptyString(); ? 45 return undefinedItemTypeString; 43 return emptyString(); 46 44 } 47 45 -
trunk/Source/WebCore/editing/HTMLInterchange.cpp
r94640 r126984 36 36 namespace WebCore { 37 37 38 namespace { 39 40 String convertedSpaceString() 38 static String convertedSpaceString() 41 39 { 42 DEFINE_STATIC_LOCAL(String, convertedSpaceString, ()); 43 if (convertedSpaceString.isNull()) { 44 convertedSpaceString = "<span class=\""; 45 convertedSpaceString += AppleConvertedSpace; 46 convertedSpaceString += "\">"; 47 convertedSpaceString.append(noBreakSpace); 48 convertedSpaceString += "</span>"; 49 } 40 DEFINE_STATIC_LOCAL(String, convertedSpaceString, (String(ASCIILiteral("<span class=\"" AppleConvertedSpace "\">")) + noBreakSpace + "</span>")); 50 41 return convertedSpaceString; 51 42 } 52 53 } // end anonymous namespace54 43 55 44 String convertHTMLTextToInterchangeFormat(const String& in, const Text* node)
Note:
See TracChangeset
for help on using the changeset viewer.