Changeset 127392 in webkit
- Timestamp:
- Sep 2, 2012 1:26:26 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r127391 r127392 1 2012-09-02 Benjamin Poulain <bpoulain@apple.com> 2 3 Improve the way we use convertedSpaceString() in convertHTMLTextToInterchangeFormat() 4 https://bugs.webkit.org/show_bug.cgi?id=95301 5 6 Reviewed by Darin Adler. 7 8 The static string convertedSpaceString() had a couple of annoying side effects: 9 -The string was 16bits due to noBreakSpace, which forced any input to be converted to 16bits. 10 -The string was kept in the heap for no particular reason. 11 12 This patch redefines convertedSpaceString as a constant literal so that we can use it efficiently. 13 14 The patch also make the binary a tiny bit smaller (700 bytes). 15 16 * editing/HTMLInterchange.cpp: 17 (WebCore::convertHTMLTextToInterchangeFormat): 18 1 19 2012-09-02 Mike West <mkwst@chromium.org> 2 20 -
trunk/Source/WebCore/editing/HTMLInterchange.cpp
r126984 r127392 36 36 namespace WebCore { 37 37 38 static String convertedSpaceString()39 {40 DEFINE_STATIC_LOCAL(String, convertedSpaceString, (String(ASCIILiteral("<span class=\"" AppleConvertedSpace "\">")) + noBreakSpace + "</span>"));41 return convertedSpaceString;42 }43 44 38 String convertHTMLTextToInterchangeFormat(const String& in, const Text* node) 45 39 { … … 47 41 if (node->renderer() && node->renderer()->style()->preserveNewline()) 48 42 return in; 43 44 const char convertedSpaceString[] = "<span class=\"" AppleConvertedSpace "\">\xA0</span>"; 45 COMPILE_ASSERT((static_cast<unsigned char>('\xA0') == noBreakSpace), ConvertedSpaceStringSpaceIsNoBreakSpace); 49 46 50 47 StringBuilder s; … … 65 62 switch (add) { 66 63 case 0: 67 s.append (convertedSpaceString());64 s.appendLiteral(convertedSpaceString); 68 65 s.append(' '); 69 s.append (convertedSpaceString());66 s.appendLiteral(convertedSpaceString); 70 67 add = 3; 71 68 break; 72 69 case 1: 73 70 if (i == 0 || i + 1 == in.length()) // at start or end of string 74 s.append (convertedSpaceString());71 s.appendLiteral(convertedSpaceString); 75 72 else 76 73 s.append(' '); … … 79 76 if (i == 0) { 80 77 // at start of string 81 s.append (convertedSpaceString());78 s.appendLiteral(convertedSpaceString); 82 79 s.append(' '); 83 80 } else if (i + 2 == in.length()) { 84 81 // at end of string 85 s.append (convertedSpaceString());86 s.append (convertedSpaceString());82 s.appendLiteral(convertedSpaceString); 83 s.appendLiteral(convertedSpaceString); 87 84 } else { 88 s.append (convertedSpaceString());85 s.appendLiteral(convertedSpaceString); 89 86 s.append(' '); 90 87 }
Note: See TracChangeset
for help on using the changeset viewer.