Bug 111789

Summary: HTMLTreeBuilder::ExternalCharacterTokenBuffer should not need to copy bytes in the CompactHTMLToken case
Product: WebKit Reporter: Eric Seidel (no email) <eric>
Component: Tools / TestsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED CONFIGURATION CHANGED    
Severity: Normal CC: abarth, annevk, tonyg
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 111645    

Description Eric Seidel (no email) 2013-03-07 16:09:49 PST
HTMLTreeBuilder::ExternalCharacterTokenBuffer should not need to copy bytes in the CompactHTMLToken case

CompactHTMLToken has already allocated a StringImpl of the right size in the common case.  We need to plumb this information through AtomicHTMLToken so that ExternalCharacterTokenBuffer can avoid copying the bytes and instead just ref the StringImpl. :)

e.g.
        m_tree.insertTextNode(buffer.takeRemaining());

profiling Parser/html-parser-threaded.html with bug 107236 applied:

Running Time	Self		Symbol Name
84.2ms    4.8%	84.2	 	WTF::fastMalloc(unsigned long)
19.6ms    1.1%	0.0	 	 WTF::StringImpl::createUninitialized(unsigned int, unsigned char*&)
17.7ms    1.0%	0.0	 	  WTF::String::make8BitFrom16BitSource(unsigned short const*, unsigned long)
8.3ms    0.4%	0.0	 	   WebCore::HTMLTreeBuilder::processCharacterBufferForInBody(WebCore::HTMLTreeBuilder::ExternalCharacterTokenBuffer&)

The .4% spent in HTMLTreeBuilder::processCharacterBufferForInBody are likely all unnecessary.
Comment 1 Anne van Kesteren 2023-04-01 00:52:28 PDT
It looks like we're doing this today.