<?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>44884</bug_id>
          
          <creation_ts>2010-08-30 12:14:47 -0700</creation_ts>
          <short_desc>Improve BlobBuilder to combine adjacent strings</short_desc>
          <delta_ts>2010-08-31 13:50:43 -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>WebCore JavaScript</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jian Li">jianli</reporter>
          <assigned_to name="Jian Li">jianli</assigned_to>
          <cc>dimich</cc>
    
    <cc>fishd</cc>
    
    <cc>kinuko</cc>
    
    <cc>levin</cc>
    
    <cc>michaeln</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>271554</commentid>
    <comment_count>0</comment_count>
    <who name="Jian Li">jianli</who>
    <bug_when>2010-08-30 12:14:47 -0700</bug_when>
    <thetext>Improve BlobBuilder to combine adjacent strings.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>271556</commentid>
    <comment_count>1</comment_count>
      <attachid>65936</attachid>
    <who name="Jian Li">jianli</who>
    <bug_when>2010-08-30 12:16:06 -0700</bug_when>
    <thetext>Created attachment 65936
Proposed Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>271583</commentid>
    <comment_count>2</comment_count>
    <who name="Kinuko Yasuda">kinuko</who>
    <bug_when>2010-08-30 12:51:03 -0700</bug_when>
    <thetext>(In reply to comment #1)
&gt; Created an attachment (id=65936) [details]
&gt; Proposed Patch

I wonder if this may end up copying strings too many times.
What if the user script calls blobBuilder.append(string) hundreds of times?
Can&apos;t we put a FIXME to optimize the performance later or isn&apos;t it better to concatenate the strings at once on getBlob()?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>272181</commentid>
    <comment_count>3</comment_count>
    <who name="Jian Li">jianli</who>
    <bug_when>2010-08-31 10:24:19 -0700</bug_when>
    <thetext>Committed as http://trac.webkit.org/changeset/66499.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>272183</commentid>
    <comment_count>4</comment_count>
    <who name="Jian Li">jianli</who>
    <bug_when>2010-08-31 10:24:58 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; (In reply to comment #1)
&gt; &gt; Created an attachment (id=65936) [details] [details]
&gt; &gt; Proposed Patch
&gt; 
&gt; I wonder if this may end up copying strings too many times.
&gt; What if the user script calls blobBuilder.append(string) hundreds of times?
&gt; Can&apos;t we put a FIXME to optimize the performance later or isn&apos;t it better to concatenate the strings at once on getBlob()?

I think it is fine since this is what we also do for combining string in form data.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>272317</commentid>
    <comment_count>5</comment_count>
    <who name="Kinuko Yasuda">kinuko</who>
    <bug_when>2010-08-31 13:28:05 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; (In reply to comment #2)
&gt; &gt; (In reply to comment #1)
&gt; &gt; &gt; Created an attachment (id=65936) [details] [details] [details]
&gt; &gt; &gt; Proposed Patch
&gt; &gt; 
&gt; &gt; I wonder if this may end up copying strings too many times.
&gt; &gt; What if the user script calls blobBuilder.append(string) hundreds of times?
&gt; &gt; Can&apos;t we put a FIXME to optimize the performance later or isn&apos;t it better to concatenate the strings at once on getBlob()?
&gt; 
&gt; I think it is fine since this is what we also do for combining string in form data.

Do you mean FormData::appendData()?
It calls Vector.grow() which utilizes memory (slightly) more efficiently and does not copy the original data if the new size fits in the reserved capacity.  (I was wondering why we don&apos;t simply use Vector.append() though.)
In this patch every time we call append we copy both original and new strings.
It may make sense in a bigger redesign but I don&apos;t quite get it why we needed this particular small change separately.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>272335</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Nordman">michaeln</who>
    <bug_when>2010-08-31 13:50:43 -0700</bug_when>
    <thetext>&gt; &gt; &gt; I wonder if this may end up copying strings too many times.
&gt; &gt; &gt; What if the user script calls blobBuilder.append(string) hundreds of times?
&gt; &gt; &gt; Can&apos;t we put a FIXME to optimize the performance later or isn&apos;t it better to concatenate the strings at once on getBlob()?
&gt; &gt; 
&gt; &gt; I think it is fine since this is what we also do for combining string in form data.
&gt; 
&gt; Do you mean FormData::appendData()?
&gt; It calls Vector.grow() which utilizes memory (slightly) more efficiently and does not copy the original data if the new size fits in the reserved capacity.  (I was wondering why we don&apos;t simply use Vector.append() though.)
&gt; In this patch every time we call append we copy both original and new strings.
&gt; It may make sense in a bigger redesign but I don&apos;t quite get it why we needed this particular small change separately.

I agree with kinuko about this particular patch not really helping the matter. Maybe we should leave the code as is until something more thoughtful is put together.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>65936</attachid>
            <date>2010-08-30 12:16:06 -0700</date>
            <delta_ts>2010-08-30 12:19:40 -0700</delta_ts>
            <desc>Proposed Patch</desc>
            <filename>44884</filename>
            <type>text/plain</type>
            <size>1808</size>
            <attacher name="Jian Li">jianli</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1dlYkNvcmUvQ2hhbmdlTG9nIGIvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXgg
YWRjZjNiYy4uYWZiZDNjNiAxMDA2NDQKLS0tIGEvV2ViQ29yZS9DaGFuZ2VMb2cKKysrIGIvV2Vi
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nNpemUo
KSAtIDFdLmRhdGEsIGNzdHIpOworICAgIGVsc2UKKyAgICAgICAgbV9pdGVtcy5hcHBlbmQoQmxv
YkRhdGFJdGVtKGNzdHIpKTsKICAgICByZXR1cm4gdHJ1ZTsKIH0KIAo=
</data>
<flag name="review"
          id="54808"
          type_id="1"
          status="+"
          setter="fishd"
    />
    <flag name="commit-queue"
          id="54809"
          type_id="3"
          status="-"
          setter="jianli"
    />
          </attachment>
      

    </bug>

</bugzilla>