Bug 150034

Summary: "A + B" with strings shouldn't copy if A or B is empty.
Product: WebKit Reporter: Andreas Kling <kling>
Component: Web Template FrameworkAssignee: Andreas Kling <kling>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cmarcelo, commit-queue, keith_miller, kling
Priority: P2 Keywords: Performance
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Andreas Kling
Reported 2015-10-12 10:45:59 PDT
Doing A + B where A and B are string types will currently always allocate a new StringImpl C with length A.length+B.length, and then blit the contents of A and B into C. We should have a fast path for A + B where A.length == 0 || B.length == 0.
Attachments
Patch (26.64 KB, patch)
2015-10-12 10:50 PDT, Andreas Kling
no flags
Andreas Kling
Comment 1 2015-10-12 10:50:45 PDT
WebKit Commit Bot
Comment 2 2015-10-12 12:45:27 PDT
Comment on attachment 262899 [details] Patch Clearing flags on attachment: 262899 Committed r190882: <http://trac.webkit.org/changeset/190882>
WebKit Commit Bot
Comment 3 2015-10-12 12:45:30 PDT
All reviewed patches have been landed. Closing bug.
Keith Miller
Comment 4 2015-10-14 07:02:57 PDT
It looks like this patch is breaking the jsc command line REPL. If you try: DYLD_FRAMEWORK_PATH=Safari-Gala-Production-SafariTen-190882-76008.app/Contents/Frameworks ./Safari-Gala-Production-SafariTen-190882-76008.app/Contents/Resources/jsc >>> foo = 1 Exception: ReferenceError: Can't find variable: f
Andreas Kling
Comment 5 2015-10-14 09:23:50 PDT
(In reply to comment #4) > It looks like this patch is breaking the jsc command line REPL. If you try: > > DYLD_FRAMEWORK_PATH=Safari-Gala-Production-SafariTen-190882-76008.app/ > Contents/Frameworks > ./Safari-Gala-Production-SafariTen-190882-76008.app/Contents/Resources/jsc > >>> foo = 1 > Exception: ReferenceError: Can't find variable: f Oh dang! I see what the bug is: StringTypeAdapter<const UChar*>::toString() always uses length=1 instead of the provided character count. Crazy that no test caught this. Will fix shortly.
Note You need to log in before you can comment on or make changes to this bug.