Bug 95924 - Deploy StringBuilder in more places in WebKit2
Summary: Deploy StringBuilder in more places in WebKit2
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-05 19:00 PDT by Jinwoo Song
Modified: 2012-09-06 22:34 PDT (History)
7 users (show)

See Also:


Attachments
patch (2.58 KB, patch)
2012-09-05 19:03 PDT, Jinwoo Song
gtk-ews: commit-queue-
Details | Formatted Diff | Diff
patch (6.07 KB, patch)
2012-09-05 20:03 PDT, Jinwoo Song
buildbot: commit-queue-
Details | Formatted Diff | Diff
patch. build error fix. (deleted)
2012-09-05 20:28 PDT, Jinwoo Song
buildbot: commit-queue-
Details | Formatted Diff | Diff
fixed typo. :( (6.33 KB, patch)
2012-09-05 21:55 PDT, Jinwoo Song
no flags Details | Formatted Diff | Diff
new patch. Applied ryuan's comments. (6.32 KB, patch)
2012-09-05 22:17 PDT, Jinwoo Song
no flags Details | Formatted Diff | Diff
patch. (6.37 KB, patch)
2012-09-05 22:33 PDT, Jinwoo Song
no flags Details | Formatted Diff | Diff
patch applied comments from Ryuan and Benjamin (6.66 KB, patch)
2012-09-06 18:25 PDT, Jinwoo Song
no flags Details | Formatted Diff | Diff
add ChangeLog (7.80 KB, patch)
2012-09-06 18:31 PDT, Jinwoo Song
no flags Details | Formatted Diff | Diff
patch. (7.81 KB, patch)
2012-09-06 19:06 PDT, Jinwoo Song
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jinwoo Song 2012-09-05 19:00:11 PDT
Deploy StringBuilder to concatenate strings more efficiently.
Comment 1 Jinwoo Song 2012-09-05 19:03:58 PDT
Created attachment 162394 [details]
patch
Comment 2 kov's GTK+ EWS bot 2012-09-05 19:18:35 PDT
Comment on attachment 162394 [details]
patch

Attachment 162394 [details] did not pass gtk-ews (gtk):
Output: http://queues.webkit.org/results/13772121
Comment 3 Build Bot 2012-09-05 19:23:29 PDT
Comment on attachment 162394 [details]
patch

Attachment 162394 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/13772125
Comment 4 Build Bot 2012-09-05 19:41:34 PDT
Comment on attachment 162394 [details]
patch

Attachment 162394 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/13774119
Comment 5 Jinwoo Song 2012-09-05 20:03:04 PDT
Created attachment 162398 [details]
patch
Comment 6 Build Bot 2012-09-05 20:27:13 PDT
Comment on attachment 162398 [details]
patch

Attachment 162398 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/13772137
Comment 7 Jinwoo Song 2012-09-05 20:28:58 PDT
Created attachment 162403 [details]
patch. build error fix.
Comment 8 Build Bot 2012-09-05 20:35:20 PDT
Comment on attachment 162403 [details]
patch. build error fix.

Attachment 162403 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/13768206
Comment 9 Build Bot 2012-09-05 20:59:25 PDT
Comment on attachment 162403 [details]
patch. build error fix.

Attachment 162403 [details] did not pass win-ews (win):
Output: http://queues.webkit.org/results/13765458
Comment 10 Ryuan Choi 2012-09-05 21:19:06 PDT
Comment on attachment 162403 [details]
patch. build error fix.

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

> Source/WebKit2/Shared/WebMemorySampler.cpp:141
> +    processDetails.appendLiteral("\n");

append('\n') looks better.

> Source/WebKit2/Shared/WebMemorySampler.cpp:142
> +    writeToFile(m_sampleLogFile, processDetails.toString().utf8().data(), processDetails.toString().utf8().length());

I am not sure, but isn't it better to keep String reference instead of using toString twice ?

> Source/WebKit2/Shared/WebMemorySampler.cpp:153
> +    header.appendLiteral("\n");
> +    writeToFile(m_sampleLogFile, header.toString().utf8().data(), header.toString().utf8().length());

Ditto.

> Source/WebKit2/Shared/WebMemorySampler.cpp:184
> +    statString.appendLiteral("\n");
> +    writeToFile(m_sampleLogFile, statString.toString().utf8().data(), statString.toString().utf8().length());

Ditto.

> Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:127
> +    etringBuilder result;

Typo
Comment 11 Early Warning System Bot 2012-09-05 21:41:27 PDT
Comment on attachment 162403 [details]
patch. build error fix.

Attachment 162403 [details] did not pass qt-wk2-ews (qt):
Output: http://queues.webkit.org/results/13765470
Comment 12 Jinwoo Song 2012-09-05 21:55:43 PDT
Created attachment 162414 [details]
fixed typo. :(
Comment 13 Jinwoo Song 2012-09-05 22:17:28 PDT
Created attachment 162419 [details]
new patch. Applied ryuan's comments.
Comment 14 Jinwoo Song 2012-09-05 22:33:19 PDT
Created attachment 162421 [details]
patch.
Comment 15 Jinwoo Song 2012-09-05 22:58:53 PDT
(In reply to comment #10)
> (From update of attachment 162403 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=162403&action=review
> 
> > Source/WebKit2/Shared/WebMemorySampler.cpp:141
> > +    processDetails.appendLiteral("\n");
> 
> append('\n') looks better.
done.

> 
> > Source/WebKit2/Shared/WebMemorySampler.cpp:142
> > +    writeToFile(m_sampleLogFile, processDetails.toString().utf8().data(), processDetails.toString().utf8().length());
> 
> I am not sure, but isn't it better to keep String reference instead of using toString twice ?
done. 
> 
> > Source/WebKit2/Shared/WebMemorySampler.cpp:153
> > +    header.appendLiteral("\n");
> > +    writeToFile(m_sampleLogFile, header.toString().utf8().data(), header.toString().utf8().length());
> 
> Ditto.
done.

> 
> > Source/WebKit2/Shared/WebMemorySampler.cpp:184
> > +    statString.appendLiteral("\n");
> > +    writeToFile(m_sampleLogFile, statString.toString().utf8().data(), statString.toString().utf8().length());
> 
> Ditto.
done.

> 
> > Source/WebKit2/WebProcess/Plugins/Netscape/NetscapeBrowserFuncs.cpp:127
> > +    etringBuilder result;
> 
> Typo
done.
Comment 16 Ryuan Choi 2012-09-06 06:03:29 PDT
Comment on attachment 162421 [details]
patch.

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

It looks almost fine to me.

Below are some nit.

> Source/WebKit2/ChangeLog:9
> + 

one space.

> Source/WebKit2/Shared/WebMemorySampler.cpp:49
> +    : m_separator(ASCIILiteral("\t"))  

remove spaces at end of lien.

> Source/WebKit2/Shared/WebMemorySampler.cpp:151
>              header.append(stats.keys[i].utf8().data());

stats.keys[i] looks enough.

> Source/WebKit2/Shared/WebMemorySampler.cpp:176
> +    StringBuilder statString; 

space.

> Source/WebKit2/Shared/WebMemorySampler.cpp:187
> +    statString.append('\n');
> +    

ditto.
Comment 17 Benjamin Poulain 2012-09-06 12:56:36 PDT
Comment on attachment 162421 [details]
patch.

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

All the changes are good ideas, but we can do even better. Some comments:

>> Source/WebKit2/Shared/WebMemorySampler.cpp:49
>> -    : m_separator(String("\t"))  
>> +    : m_separator(ASCIILiteral("\t"))  
> 
> remove spaces at end of lien.

Reading WebMemorySampler, m_separator is a bad idea, you should get rid of it.

You can just have
const char separator = '\t'; in the cpp file.

> Source/WebKit2/Shared/WebMemorySampler.cpp:141
> -    String processDetails = String("Process: ");
> +    StringBuilder processDetails;
> +    processDetails.appendLiteral("Process: ");
>      processDetails.append(processName());
> -    processDetails.append(String("\n"));
> -    writeToFile(m_sampleLogFile, processDetails.utf8().data(), processDetails.utf8().length());
> +    processDetails.append('\n');

Since there is no branch, it is more interesting to use the String Operators:
    String processDetails = "Process: " + processName() + '\n';

> Source/WebKit2/Shared/WebMemorySampler.cpp:186
>              statString.append(String::number(memoryStats.values[i]));
>          }
>      }
> -    statString.append(String("\n"));
> -    writeToFile(m_sampleLogFile, statString.utf8().data(), statString.utf8().length());
> +    statString.append('\n');

This one is a big win with StringBuilder.

> Source/WebKit2/WebProcess/WebCoreSupport/WebContextMenuClient.cpp:87
> -    String url("http://www.google.com/search?q=");
> +    StringBuilder url;
> +    url.appendLiteral("http://www.google.com/search?q=");
>      url.append(encoded);
> -    url.append("&ie=UTF-8&oe=UTF-8");
> +    url.appendLiteral("&ie=UTF-8&oe=UTF-8");

This should use String Operators:
    url = "http://www.google.com/search?q=" + encoded + "&ie=UTF-8&oe=UTF-8";
Comment 18 Jinwoo Song 2012-09-06 18:25:57 PDT
Created attachment 162637 [details]
patch applied comments from Ryuan and Benjamin
Comment 19 Jinwoo Song 2012-09-06 18:31:53 PDT
Created attachment 162640 [details]
add ChangeLog

Applied comments by Ryuan and Benjamin. Thanks for scrupulous review!
Comment 20 Ryuan Choi 2012-09-06 18:38:36 PDT
Comment on attachment 162637 [details]
patch applied comments from Ryuan and Benjamin

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

I think that this patch can be landed?

Why don't you add changelog and r?

> Source/WebKit2/Shared/WebMemorySampler.cpp:39
> +const char separator = '\t';

nit. static const char?
Comment 21 Jinwoo Song 2012-09-06 19:06:28 PDT
Created attachment 162649 [details]
patch.
Comment 22 Benjamin Poulain 2012-09-06 19:08:07 PDT
> > Source/WebKit2/Shared/WebMemorySampler.cpp:39
> > +const char separator = '\t';
> 
> nit. static const char?

Out of curiosity, why?
Comment 23 Ryuan Choi 2012-09-06 21:37:49 PDT
(In reply to comment #22)
> > > Source/WebKit2/Shared/WebMemorySampler.cpp:39
> > > +const char separator = '\t';
> > 
> > nit. static const char?
> 
> Out of curiosity, why?

Just to clarify the scope.
It will be same irrespective of 'static'

Am I right?
Comment 24 Benjamin Poulain 2012-09-06 22:12:19 PDT
> > Out of curiosity, why?
> 
> Just to clarify the scope.
> It will be same irrespective of 'static'
> 
> Am I right?

That is right. I was thinking the value will likely end up in the __text segment anyway so why bother with static... But I see your point about making the scope explicit.
Comment 25 WebKit Review Bot 2012-09-06 22:34:10 PDT
Comment on attachment 162649 [details]
patch.

Clearing flags on attachment: 162649

Committed r127828: <http://trac.webkit.org/changeset/127828>
Comment 26 WebKit Review Bot 2012-09-06 22:34:15 PDT
All reviewed patches have been landed.  Closing bug.