Bug 32454

Summary: Refactor construction of simple strings to avoid string concatenation.
Product: WebKit Reporter: Gavin Barraclough <barraclough>
Component: JavaScriptCoreAssignee: Gavin Barraclough <barraclough>
Severity: Normal CC: webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: OS X 10.5   
Description Flags
The patch oliver: review+

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

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