<?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>98299</bug_id>
          
          <creation_ts>2012-10-03 14:16:09 -0700</creation_ts>
          <short_desc>String::remove will convert an 8 bit string to a 16 bit string</short_desc>
          <delta_ts>2022-02-27 23:24:35 -0800</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>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="Michael Saboff">msaboff</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>benjamin</cc>
    
    <cc>webkit.review.bot</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>734023</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Saboff">msaboff</who>
    <bug_when>2012-10-03 14:16:09 -0700</bug_when>
    <thetext>The StringImpl::remove() method will up convert the contents of an 8 bit string and the result will always be a 16 bit string.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>734028</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Saboff">msaboff</who>
    <bug_when>2012-10-03 14:19:41 -0700</bug_when>
    <thetext>The remove method is actually in WTFString.cpp (String::remove).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>734130</commentid>
    <comment_count>2</comment_count>
      <attachid>166981</attachid>
    <who name="Michael Saboff">msaboff</who>
    <bug_when>2012-10-03 16:00:05 -0700</bug_when>
    <thetext>Created attachment 166981
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>734263</commentid>
    <comment_count>3</comment_count>
      <attachid>166981</attachid>
    <who name="Benjamin Poulain">benjamin</who>
    <bug_when>2012-10-03 17:43:16 -0700</bug_when>
    <thetext>Comment on attachment 166981
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=166981&amp;action=review

&gt; Source/WTF/wtf/text/WTFString.cpp:281
&gt;      if (static_cast&lt;unsigned&gt;(lengthToRemove) &gt; length() - position)
&gt;          lengthToRemove = length() - position;

No idea if that case is common.
If it is, shouldn&apos;t we just return a substring sharing impl here?

&gt; Source/WTF/wtf/text/WTFString.cpp:289
&gt; +        RefPtr&lt;StringImpl&gt; newImpl = StringImpl::createUninitialized(length() - lengthToRemove, data);
&gt; +        memcpy(data, characters8(), position * sizeof(LChar));
&gt; +        memcpy(data + position, characters8() + position + lengthToRemove,
&gt; +            (length() - lengthToRemove - position) * sizeof(LChar));
&gt; +        m_impl = newImpl.release();

I would do an inline template with that code taking CharacterType as argument.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>734769</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Saboff">msaboff</who>
    <bug_when>2012-10-04 09:44:35 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; (From update of attachment 166981 [details])
&gt; View in context: https://bugs.webkit.org/attachment.cgi?id=166981&amp;action=review
&gt; 
&gt; &gt; Source/WTF/wtf/text/WTFString.cpp:281
&gt; &gt;      if (static_cast&lt;unsigned&gt;(lengthToRemove) &gt; length() - position)
&gt; &gt;          lengthToRemove = length() - position;
&gt; 
&gt; No idea if that case is common.
&gt; If it is, shouldn&apos;t we just return a substring sharing impl here?

From what I&apos;ve seen, the use of remove is within length range and this wouldn&apos;t help.

&gt; &gt; Source/WTF/wtf/text/WTFString.cpp:289
&gt; &gt; +        RefPtr&lt;StringImpl&gt; newImpl = StringImpl::createUninitialized(length() - lengthToRemove, data);
&gt; &gt; +        memcpy(data, characters8(), position * sizeof(LChar));
&gt; &gt; +        memcpy(data + position, characters8() + position + lengthToRemove,
&gt; &gt; +            (length() - lengthToRemove - position) * sizeof(LChar));
&gt; &gt; +        m_impl = newImpl.release();
&gt; 
&gt; I would do an inline template with that code taking CharacterType as argument.

Done.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>734770</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Saboff">msaboff</who>
    <bug_when>2012-10-04 09:45:17 -0700</bug_when>
    <thetext>Committed r130404: &lt;http://trac.webkit.org/changeset/130404&gt;</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>166981</attachid>
            <date>2012-10-03 16:00:05 -0700</date>
            <delta_ts>2022-02-27 23:24:35 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>98299.patch</filename>
            <type>text/plain</type>
            <size>1966</size>
            <attacher name="Michael Saboff">msaboff</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XVEYvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFNvdXJjZS9XVEYvQ2hh
bmdlTG9nCShyZXZpc2lvbiAxMzAzMzUpCisrKyBTb3VyY2UvV1RGL0NoYW5nZUxvZwkod29ya2lu
ZyBjb3B5KQpAQCAtMSwzICsxLDE1IEBACisyMDEyLTEwLTAzICBNaWNoYWVsIFNhYm9mZiAgPG1z
YWJvZmZAYXBwbGUuY29tPgorCisgICAgICAgIFN0cmluZzo6cmVtb3ZlIHdpbGwgY29udmVydCBh
biA4IGJpdCBzdHJpbmcgdG8gYSAxNiBiaXQgc3RyaW5nCisgICAgICAgIGh0dHBzOi8vYnVncy53
ZWJraXQub3JnL3Nob3dfYnVnLmNnaT9pZD05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"
          type_id="1"
          status="+"
          setter="benjamin"
    />
          </attachment>
      

    </bug>

</bugzilla>