Bug 32454 - Refactor construction of simple strings to avoid string concatenation.
Summary: Refactor construction of simple strings to avoid string concatenation.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Gavin Barraclough
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-12-11 15:20 PST by Gavin Barraclough
Modified: 2009-12-11 15:34 PST (History)
1 user (show)

See Also:


Attachments
The patch (42.12 KB, patch)
2009-12-11 15:25 PST, Gavin Barraclough
oliver: 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 2009-12-11 15:20:10 PST
Building strings through concatenation has a memory and performance cost – a memory cost since we must over-allocate the buffer to leave space to append into, and performance in that the string may still require reallocation (and thus copying during construction).  Instead move the full construction to within a single function call (makeString), so that the arguments' lengths can be calculated and an appropriate sized buffer allocated before copying any characters.
Comment 1 Gavin Barraclough 2009-12-11 15:25:16 PST
Created attachment 44713 [details]
The patch
Comment 2 WebKit Review Bot 2009-12-11 15:26:05 PST
Attachment 44713 [details] did not pass style-queue:

Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
JavaScriptCore/runtime/UString.h:547:  This { should be at the end of the previous line  [whitespace/braces] [4]
JavaScriptCore/runtime/UString.h:570:  This { should be at the end of the previous line  [whitespace/braces] [4]
JavaScriptCore/runtime/UString.h:593:  This { should be at the end of the previous line  [whitespace/braces] [4]
Total errors found: 3
Comment 3 Oliver Hunt 2009-12-11 15:30:37 PST
Comment on attachment 44713 [details]
The patch

rme=
Comment 4 Gavin Barraclough 2009-12-11 15:34:22 PST
Transmitting file data .................
Committed revision 52028.