Changeset 81937 in webkit
- Timestamp:
- Mar 24, 2011, 9:10:59 PM (14 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r81933 r81937 1 2011-03-24 Stephanie Lewis <slewis@apple.com> 2 3 Reviewed by Geoff Garen. 4 5 https://bugs.webkit.org/show_bug.cgi?id=57073 6 Rework the AtomicHTMLConstructor to reserve space for attributes based on the size of the attribute list. 7 Saves 1.5 MB on Membuster. 8 9 No new tests because there was no change in behavior. Current tests pass. 10 11 * html/parser/HTMLToken.h: 12 (WebCore::AtomicHTMLToken::AtomicHTMLToken): 13 (WebCore::AtomicHTMLToken::initializeAttributes): 14 1 15 2011-03-24 Sheriff Bot <webkit.review.bot@gmail.com> 2 16 -
trunk/Source/WebCore/html/parser/HTMLToken.h
r77057 r81937 399 399 m_selfClosing = token.selfClosing(); 400 400 m_name = AtomicString(token.name().data(), token.name().size()); 401 const HTMLToken::AttributeList& attributes = token.attributes(); 402 for (HTMLToken::AttributeList::const_iterator iter = attributes.begin(); 403 iter != attributes.end(); ++iter) { 404 if (!iter->m_name.isEmpty()) { 405 String name(iter->m_name.data(), iter->m_name.size()); 406 String value(iter->m_value.data(), iter->m_value.size()); 407 ASSERT(iter->m_nameRange.m_start); 408 ASSERT(iter->m_nameRange.m_end); 409 ASSERT(iter->m_valueRange.m_start); 410 ASSERT(iter->m_valueRange.m_end); 411 RefPtr<Attribute> mappedAttribute = Attribute::createMapped(name, value); 412 if (!m_attributes) { 413 m_attributes = NamedNodeMap::create(); 414 // Reserving capacity here improves the parser 415 // benchmark. It might be worth experimenting with 416 // the constant to see where the optimal point is. 417 m_attributes->reserveInitialCapacity(10); 418 } 419 m_attributes->insertAttribute(mappedAttribute.release(), false); 420 } 421 } 401 initializeAttributes(token.attributes()); 422 402 break; 423 403 } … … 514 494 HTMLToken::Type m_type; 515 495 496 void initializeAttributes(const HTMLToken::AttributeList& attributes); 497 516 498 bool usesName() const 517 499 { … … 549 531 }; 550 532 533 inline void AtomicHTMLToken::initializeAttributes(const HTMLToken::AttributeList& attributes) 534 { 535 size_t size = attributes.size(); 536 if (!size) 537 return; 538 539 m_attributes = NamedNodeMap::create(); 540 m_attributes->reserveInitialCapacity(size); 541 for (size_t i = 0; i < size; ++i) { 542 const HTMLToken::Attribute& attribute = attributes[i]; 543 if (attribute.m_name.isEmpty()) 544 continue; 545 546 ASSERT(attribute.m_nameRange.m_start); 547 ASSERT(attribute.m_nameRange.m_end); 548 ASSERT(attribute.m_valueRange.m_start); 549 ASSERT(attribute.m_valueRange.m_end); 550 551 String name(attribute.m_name.data(), attribute.m_name.size()); 552 String value(attribute.m_value.data(), attribute.m_value.size()); 553 m_attributes->insertAttribute(Attribute::createMapped(name, value), false); 554 } 551 555 } 552 556 557 } 558 553 559 #endif
Note:
See TracChangeset
for help on using the changeset viewer.