<?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>188882</bug_id>
          
          <creation_ts>2018-08-23 04:23:27 -0700</creation_ts>
          <short_desc>String.concat() significantly slower than &apos;+&apos; operator</short_desc>
          <delta_ts>2018-08-27 02:12:12 -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>JavaScriptCore</component>
          <version>Safari 11</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Nicholas Shanks">nickshanks</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>fpizlo</cc>
    
    <cc>keith_miller</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>ysuzuki</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1453032</commentid>
    <comment_count>0</comment_count>
    <who name="Nicholas Shanks">nickshanks</who>
    <bug_when>2018-08-23 04:23:27 -0700</bug_when>
    <thetext>When String.prototype.concat() and String.prototype.join() have not been modified from their initial values, promotion of their arguments to strings and concatenation of those strings should be nearly as fast as the &apos;+&apos; operator with one string operand (which also has to promote the other operand). This will allow functional composition to be performant.

See https://jsperf.com/concat-vs-plus-vs-join-2</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1453086</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2018-08-23 09:46:38 -0700</bug_when>
    <thetext>&lt;rdar://problem/43646782&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1453834</commentid>
    <comment_count>2</comment_count>
    <who name="Keith Miller">keith_miller</who>
    <bug_when>2018-08-27 02:12:12 -0700</bug_when>
    <thetext>It looks like you are seeing such a large difference because the test is passing more than one argument to concat at the same time. This causes us to emit a loop which is slowing that code down.

If you change your test to:

string1.concat(string2).concat(string3);

you will see that the perf is quite close. In theory we could do some loop unrolling to fix this but the same issue applies to calling the &apos;+&apos; operator in a loop.

The join case is slow because it will allocate an Array, which is expensive. We could also optimize this but it&apos;s probably easier to use the concat method for now.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>