Bug 65799 - String replace with the empty string means string removal
Summary: String replace with the empty string means string removal
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-05 17:19 PDT by Gavin Barraclough
Modified: 2011-08-05 19:18 PDT (History)
1 user (show)

See Also:


Attachments
The patch (4.29 KB, patch)
2011-08-05 17:22 PDT, Gavin Barraclough
sam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gavin Barraclough 2011-08-05 17:19:22 PDT
Optimization for String.prototype.replace([RegExp], ""), this improves v8-regexp by ~3%.
Comment 1 Gavin Barraclough 2011-08-05 17:22:11 PDT
Created attachment 103133 [details]
The patch
Comment 2 WebKit Review Bot 2011-08-05 17:26:32 PDT
Attachment 103133 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/ChangeLog', u'Source..." exit_code: 1

Source/JavaScriptCore/runtime/StringPrototype.cpp:267:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
Source/JavaScriptCore/runtime/StringPrototype.cpp:271:  Local variables should never be PassRefPtr (see http://webkit.org/coding/RefPtr.html).  [readability/pass_ptr] [5]
Source/JavaScriptCore/runtime/StringPrototype.cpp:380:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
Total errors found: 3 in 2 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Sam Weinig 2011-08-05 17:34:29 PDT
Comment on attachment 103133 [details]
The patch

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

>> Source/JavaScriptCore/runtime/StringPrototype.cpp:271
>> +    PassRefPtr<StringImpl> impl = StringImpl::tryCreateUninitialized(totalLength, buffer);
> 
> Local variables should never be PassRefPtr (see http://webkit.org/coding/RefPtr.html).  [readability/pass_ptr] [5]

This is copy and pasted, but very wrong.  Please us a RefPtr and fix the other spot.
Comment 4 Gavin Barraclough 2011-08-05 19:18:15 PDT
Fixed in r92540