[Webkit-unassigned] [Bug 95924] Deploy StringBuilder in more places in WebKit2

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Sep 6 12:56:22 PDT 2012


https://bugs.webkit.org/show_bug.cgi?id=95924





--- Comment #17 from Benjamin Poulain <benjamin at webkit.org>  2012-09-06 12:56:36 PST ---
(From update of attachment 162421)
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";

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list