Changeset 154241 in webkit
- Timestamp:
- Aug 17, 2013, 3:05:27 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r154240 r154241 1 2013-08-17 Antti Koivisto <antti@apple.com> 2 3 <https://webkit.org/b/119960> Remove some optimizations made obsolete by use of StringBuilder 4 5 Reviewed by Andreas Kling. 6 7 * dom/ScriptElement.cpp: 8 (WebCore::ScriptElement::scriptContent): 9 10 StringBuilder already optimizes for the single string case. If there is only one the original string is returned. 11 12 * dom/Text.cpp: 13 (WebCore::Text::wholeText): 14 15 No need to traverse twice to compute the capacity. StringBuilder handles this efficiently. 16 Also in the common case there is only one string and the optimization here is actually hurting by disabling the StringBuilder one. 17 1 18 2013-08-17 Antti Koivisto <antti@apple.com> 2 19 -
trunk/Source/WebCore/dom/ScriptElement.cpp
r154240 r154241 395 395 String ScriptElement::scriptContent() const 396 396 { 397 StringBuilder content; 398 Text* firstTextNode = 0; 399 bool foundMultipleTextNodes = false; 400 401 for (Text* textNode = TextNodeTraversal::firstChild(m_element); textNode; textNode = TextNodeTraversal::nextSibling(textNode)) { 402 if (foundMultipleTextNodes) 403 content.append(textNode->data()); 404 else if (firstTextNode) { 405 content.append(firstTextNode->data()); 406 content.append(textNode->data()); 407 foundMultipleTextNodes = true; 408 } else 409 firstTextNode = textNode; 410 } 411 412 if (firstTextNode && !foundMultipleTextNodes) 413 return firstTextNode->data(); 414 415 return content.toString(); 397 return TextNodeTraversal::contentsAsString(m_element); 416 398 } 417 399 -
trunk/Source/WebCore/dom/Text.cpp
r154240 r154241 121 121 const Text* startText = earliestLogicallyAdjacentTextNode(this); 122 122 const Text* endText = latestLogicallyAdjacentTextNode(this); 123 124 Node* onePastEndText = TextNodeTraversal::nextSibling(endText); 125 Checked<unsigned> resultLength = 0; 126 for (const Text* text = startText; text != onePastEndText; text = TextNodeTraversal::nextSibling(text)) 127 resultLength += text->length(); 123 const Node* onePastEndText = TextNodeTraversal::nextSibling(endText); 128 124 129 125 StringBuilder result; 130 result.reserveCapacity(resultLength.unsafeGet());131 126 for (const Text* text = startText; text != onePastEndText; text = TextNodeTraversal::nextSibling(text)) 132 127 result.append(text->data()); 133 ASSERT(result.length() == resultLength.unsafeGet());134 135 128 return result.toString(); 136 129 }
Note:
See TracChangeset
for help on using the changeset viewer.