<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>111789</bug_id>
          
          <creation_ts>2013-03-07 16:09:49 -0800</creation_ts>
          <short_desc>HTMLTreeBuilder::ExternalCharacterTokenBuffer should not need to copy bytes in the CompactHTMLToken case</short_desc>
          <delta_ts>2023-04-01 00:52:28 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Tools / Tests</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>111645</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Eric Seidel (no email)">eric</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>abarth</cc>
    
    <cc>annevk</cc>
    
    <cc>tonyg</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>850585</commentid>
    <comment_count>0</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2013-03-07 16:09:49 -0800</bug_when>
    <thetext>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*&amp;)
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&amp;)

The .4% spent in HTMLTreeBuilder::processCharacterBufferForInBody are likely all unnecessary.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1945928</commentid>
    <comment_count>1</comment_count>
    <who name="Anne van Kesteren">annevk</who>
    <bug_when>2023-04-01 00:52:28 -0700</bug_when>
    <thetext>It looks like we&apos;re doing this today.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>