Bug 129466

Summary: indexOf and lastIndexOf shouldn't resolve ropes when needle is longer than haystack
Product: WebKit Reporter: Ryosuke Niwa <rniwa>
Component: JavaScriptCoreAssignee: Ryosuke Niwa <rniwa>
Status: RESOLVED FIXED    
Severity: Normal CC: barraclough, benjamin, fpizlo, ggaren, kling, oliver, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch msaboff: review+

Description Ryosuke Niwa 2014-02-27 20:38:21 PST
Right now indexOf and lastIndexOf always resolves ropes via JSString::toString.
Just return -1 before resolving ropes when needle is longer than haystack.
Comment 1 Radar WebKit Bug Importer 2014-02-27 20:39:04 PST
<rdar://problem/16192706>
Comment 2 Radar WebKit Bug Importer 2014-02-27 20:39:07 PST
<rdar://problem/16192707>
Comment 3 Ryosuke Niwa 2014-02-27 20:40:34 PST
Created attachment 225434 [details]
Patch
Comment 4 Michael Saboff 2014-02-27 21:13:50 PST
Comment on attachment 225434 [details]
Patch

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

r=me

> Source/JavaScriptCore/ChangeLog:8
> +        Refactored the code to avoid calling toString on JSString when needle is longer than haystack.

It is actually JSString::value that you are avoiding.
Comment 5 Ryosuke Niwa 2014-02-27 21:20:28 PST
Thanks for the review.

(In reply to comment #4)
> (From update of attachment 225434 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=225434&action=review
> 
> r=me
> 
> > Source/JavaScriptCore/ChangeLog:8
> > +        Refactored the code to avoid calling toString on JSString when needle is longer than haystack.
> 
> It is actually JSString::value that you are avoiding.

Oops, yes. Will fix before landing it.
Comment 6 Ryosuke Niwa 2014-02-27 21:24:33 PST
Committed r164851: <http://trac.webkit.org/changeset/164851>