[EFL] Remove '+=' usage in String

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

Patch by Kangil Han <kangil.han@samsung.com> on 2012-09-05
Reviewed by Benjamin Poulain.

Replaced use of String operator '+=' with StringBuilder.append*() in order to adopt efficient String concatenation.

Source/WebKit/efl:

* ewk/ewk_frame.cpp:
(ewk_frame_source_get): Removed unnecessary strlen usage.

Tools:

* DumpRenderTree/efl/DumpRenderTreeChrome.cpp:
(descriptionSuitableForTestResult):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@127604 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent bcd60459
2012-09-05 Kangil Han <kangil.han@samsung.com>
[EFL] Remove '+=' usage in String
https://bugs.webkit.org/show_bug.cgi?id=95808
Reviewed by Benjamin Poulain.
Replaced use of String operator '+=' with StringBuilder.append*() in order to adopt efficient String concatenation.
* ewk/ewk_frame.cpp:
(ewk_frame_source_get): Removed unnecessary strlen usage.
2012-09-05 Kaustubh Atrawalkar <kaustubh@motorola.com>
[DRT] LTC:: Move printing related APIs from LayoutTestController to Internals
......
......@@ -1638,7 +1638,7 @@ ssize_t ewk_frame_source_get(const Evas_Object* ewkFrame, char** frameSource)
EINA_SAFETY_ON_NULL_RETURN_VAL(smartData->frame->document(), -1);
EINA_SAFETY_ON_NULL_RETURN_VAL(frameSource, -1);
WTF::String source;
StringBuilder builder;
*frameSource = 0; // Saves 0 to pointer until it's not allocated.
if (!smartData->frame->document()->isHTMLDocument()) {
......@@ -1654,28 +1654,29 @@ ssize_t ewk_frame_source_get(const Evas_Object* ewkFrame, char** frameSource)
if (node->hasTagName(WebCore::HTMLNames::htmlTag)) {
WebCore::HTMLElement* element = static_cast<WebCore::HTMLElement*>(node);
if (element)
source = element->outerHTML();
builder.append(element->outerHTML());
break;
}
}
// Try to get <head> and <body> tags if <html> tag was not found.
if (source.isEmpty()) {
if (builder.isEmpty()) {
if (smartData->frame->document()->head())
source = smartData->frame->document()->head()->outerHTML();
builder.append(smartData->frame->document()->head()->outerHTML());
if (smartData->frame->document()->body())
source += smartData->frame->document()->body()->outerHTML();
builder.append(smartData->frame->document()->body()->outerHTML());
}
size_t sourceLength = strlen(source.utf8().data());
CString utf8String = builder.toString().utf8();
size_t sourceLength = utf8String.length();
*frameSource = static_cast<char*>(malloc(sourceLength + 1));
if (!*frameSource) {
CRITICAL("Could not allocate memory.");
return -1;
}
strncpy(*frameSource, source.utf8().data(), sourceLength);
strncpy(*frameSource, utf8String.data(), sourceLength);
(*frameSource)[sourceLength] = '\0';
return sourceLength;
......
2012-09-05 Kangil Han <kangil.han@samsung.com>
[EFL] Remove '+=' usage in String
https://bugs.webkit.org/show_bug.cgi?id=95808
Reviewed by Benjamin Poulain.
Replaced use of String operator '+=' with StringBuilder.append*() in order to adopt efficient String concatenation.
* DumpRenderTree/efl/DumpRenderTreeChrome.cpp:
(descriptionSuitableForTestResult):
2012-09-05 Christophe Dumez <christophe.dumez@intel.com>
[EFL][WK2] Provide implementation for TestRunner::pathToLocalResource()
......
......@@ -48,6 +48,7 @@
#include <Evas.h>
#include <cstdio>
#include <wtf/NotFound.h>
#include <wtf/text/StringBuilder.h>
using namespace WebCore;
......@@ -365,15 +366,20 @@ static CString urlSuitableForTestResult(const char* uriString)
static CString descriptionSuitableForTestResult(Ewk_Frame_Resource_Request* request)
{
String ret = "<NSURLRequest URL ";
ret += pathSuitableForTestResult(request->url).data();
ret += ", main document URL ";
ret += urlSuitableForTestResult(request->first_party).data();
ret += ", http method ";
ret += request->http_method ? String(request->http_method) : "(none)";
ret += ">";
StringBuilder builder;
builder.appendLiteral("<NSURLRequest URL ");
builder.append(pathSuitableForTestResult(request->url).data());
builder.appendLiteral(", main document URL ");
builder.append(urlSuitableForTestResult(request->first_party).data());
builder.appendLiteral(", http method ");
return ret.utf8();
if (request->http_method)
builder.append(String(request->http_method));
else
builder.appendLiteral("(none)");
builder.append('>');
return builder.toString().utf8();
}
static CString descriptionSuitableForTestResult(const Ewk_Frame_Resource_Response* response)
......@@ -381,13 +387,13 @@ static CString descriptionSuitableForTestResult(const Ewk_Frame_Resource_Respons
if (!response)
return CString("(null)");
String ret = "<NSURLResponse ";
ret += pathSuitableForTestResult(response->url).data();
ret += ", http status code ";
ret += String::number(response->status_code);
ret += ">";
return ret.utf8();
StringBuilder builder;
builder.appendLiteral("<NSURLResponse ");
builder.append(pathSuitableForTestResult(response->url).data());
builder.appendLiteral(", http status code ");
builder.append(String::number(response->status_code));
builder.append('>');
return builder.toString().utf8();
}
static CString descriptionSuitableForTestResult(Ewk_Frame_Load_Error* error)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment