- Revision
- 136589
- Author
- hara...@chromium.org
- Date
- 2012-12-04 16:27:50 -0800 (Tue, 04 Dec 2012)
Log Message
[V8] Replace String::New("symbol") with String::NewSymbol("symbol")
https://bugs.webkit.org/show_bug.cgi?id=103989
Reviewed by Adam Barth.
In V8, a symbol lookup is faster than a string lookup. We should use
String::NewSymbol("symbol") for symbols.
No tests. No change in behavior.
* bindings/v8/custom/V8DeviceMotionEventCustom.cpp:
* bindings/v8/custom/V8HTMLCanvasElementCustom.cpp:
(WebCore::V8HTMLCanvasElement::getContextCallback):
* bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
(WebCore::V8InjectedScriptHost::typeCallback):
(WebCore::V8InjectedScriptHost::functionDetailsCallback):
(WebCore::getJSListenerFunctions):
* bindings/v8/custom/V8InspectorFrontendHostCustom.cpp:
(WebCore::populateContextMenuItems):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (136588 => 136589)
--- trunk/Source/WebCore/ChangeLog 2012-12-05 00:25:44 UTC (rev 136588)
+++ trunk/Source/WebCore/ChangeLog 2012-12-05 00:27:50 UTC (rev 136589)
@@ -1,3 +1,25 @@
+2012-12-04 Kentaro Hara <hara...@chromium.org>
+
+ [V8] Replace String::New("symbol") with String::NewSymbol("symbol")
+ https://bugs.webkit.org/show_bug.cgi?id=103989
+
+ Reviewed by Adam Barth.
+
+ In V8, a symbol lookup is faster than a string lookup. We should use
+ String::NewSymbol("symbol") for symbols.
+
+ No tests. No change in behavior.
+
+ * bindings/v8/custom/V8DeviceMotionEventCustom.cpp:
+ * bindings/v8/custom/V8HTMLCanvasElementCustom.cpp:
+ (WebCore::V8HTMLCanvasElement::getContextCallback):
+ * bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
+ (WebCore::V8InjectedScriptHost::typeCallback):
+ (WebCore::V8InjectedScriptHost::functionDetailsCallback):
+ (WebCore::getJSListenerFunctions):
+ * bindings/v8/custom/V8InspectorFrontendHostCustom.cpp:
+ (WebCore::populateContextMenuItems):
+
2012-12-04 Julien Chaffraix <jchaffr...@webkit.org>
[CSS Grid Layout] Implement CSS parsing and handling for <track-minmax>
Modified: trunk/Source/WebCore/bindings/v8/custom/V8DeviceMotionEventCustom.cpp (136588 => 136589)
--- trunk/Source/WebCore/bindings/v8/custom/V8DeviceMotionEventCustom.cpp 2012-12-05 00:25:44 UTC (rev 136588)
+++ trunk/Source/WebCore/bindings/v8/custom/V8DeviceMotionEventCustom.cpp 2012-12-05 00:27:50 UTC (rev 136589)
@@ -40,18 +40,18 @@
static v8::Handle<v8::Value> createAccelerationObject(const DeviceMotionData::Acceleration* acceleration, v8::Isolate* isolate)
{
v8::Local<v8::Object> object = v8::Object::New();
- object->Set(v8::String::New("x"), acceleration->canProvideX() ? v8::Number::New(acceleration->x()) : v8::Null(isolate));
- object->Set(v8::String::New("y"), acceleration->canProvideY() ? v8::Number::New(acceleration->y()) : v8::Null(isolate));
- object->Set(v8::String::New("z"), acceleration->canProvideZ() ? v8::Number::New(acceleration->z()) : v8::Null(isolate));
+ object->Set(v8::String::NewSymbol("x"), acceleration->canProvideX() ? v8::Number::New(acceleration->x()) : v8::Null(isolate));
+ object->Set(v8::String::NewSymbol("y"), acceleration->canProvideY() ? v8::Number::New(acceleration->y()) : v8::Null(isolate));
+ object->Set(v8::String::NewSymbol("z"), acceleration->canProvideZ() ? v8::Number::New(acceleration->z()) : v8::Null(isolate));
return object;
}
static v8::Handle<v8::Value> createRotationRateObject(const DeviceMotionData::RotationRate* rotationRate, v8::Isolate* isolate)
{
v8::Local<v8::Object> object = v8::Object::New();
- object->Set(v8::String::New("alpha"), rotationRate->canProvideAlpha() ? v8::Number::New(rotationRate->alpha()) : v8::Null(isolate));
- object->Set(v8::String::New("beta"), rotationRate->canProvideBeta() ? v8::Number::New(rotationRate->beta()) : v8::Null(isolate));
- object->Set(v8::String::New("gamma"), rotationRate->canProvideGamma() ? v8::Number::New(rotationRate->gamma()) : v8::Null(isolate));
+ object->Set(v8::String::NewSymbol("alpha"), rotationRate->canProvideAlpha() ? v8::Number::New(rotationRate->alpha()) : v8::Null(isolate));
+ object->Set(v8::String::NewSymbol("beta"), rotationRate->canProvideBeta() ? v8::Number::New(rotationRate->beta()) : v8::Null(isolate));
+ object->Set(v8::String::NewSymbol("gamma"), rotationRate->canProvideGamma() ? v8::Number::New(rotationRate->gamma()) : v8::Null(isolate));
return object;
}
@@ -63,19 +63,19 @@
// Given the test above, this will always yield an object.
v8::Local<v8::Object> object = value->ToObject();
- v8::Local<v8::Value> xValue = object->Get(v8::String::New("x"));
+ v8::Local<v8::Value> xValue = object->Get(v8::String::NewSymbol("x"));
if (xValue.IsEmpty())
return 0;
bool canProvideX = !isUndefinedOrNull(xValue);
double x = xValue->NumberValue();
- v8::Local<v8::Value> yValue = object->Get(v8::String::New("y"));
+ v8::Local<v8::Value> yValue = object->Get(v8::String::NewSymbol("y"));
if (yValue.IsEmpty())
return 0;
bool canProvideY = !isUndefinedOrNull(yValue);
double y = yValue->NumberValue();
- v8::Local<v8::Value> zValue = object->Get(v8::String::New("z"));
+ v8::Local<v8::Value> zValue = object->Get(v8::String::NewSymbol("z"));
if (zValue.IsEmpty())
return 0;
bool canProvideZ = !isUndefinedOrNull(zValue);
@@ -95,19 +95,19 @@
// Given the test above, this will always yield an object.
v8::Local<v8::Object> object = value->ToObject();
- v8::Local<v8::Value> alphaValue = object->Get(v8::String::New("alpha"));
+ v8::Local<v8::Value> alphaValue = object->Get(v8::String::NewSymbol("alpha"));
if (alphaValue.IsEmpty())
return 0;
bool canProvideAlpha = !isUndefinedOrNull(alphaValue);
double alpha = alphaValue->NumberValue();
- v8::Local<v8::Value> betaValue = object->Get(v8::String::New("beta"));
+ v8::Local<v8::Value> betaValue = object->Get(v8::String::NewSymbol("beta"));
if (betaValue.IsEmpty())
return 0;
bool canProvideBeta = !isUndefinedOrNull(betaValue);
double beta = betaValue->NumberValue();
- v8::Local<v8::Value> gammaValue = object->Get(v8::String::New("gamma"));
+ v8::Local<v8::Value> gammaValue = object->Get(v8::String::NewSymbol("gamma"));
if (gammaValue.IsEmpty())
return 0;
bool canProvideGamma = !isUndefinedOrNull(gammaValue);
Modified: trunk/Source/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp (136588 => 136589)
--- trunk/Source/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp 2012-12-05 00:25:44 UTC (rev 136588)
+++ trunk/Source/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp 2012-12-05 00:27:50 UTC (rev 136589)
@@ -61,22 +61,22 @@
WebGLContextAttributes* webGLAttrs = static_cast<WebGLContextAttributes*>(attrs.get());
if (args.Length() > 1 && args[1]->IsObject()) {
v8::Handle<v8::Object> jsAttrs = args[1]->ToObject();
- v8::Handle<v8::String> alpha = v8::String::New("alpha");
+ v8::Handle<v8::String> alpha = v8::String::NewSymbol("alpha");
if (jsAttrs->Has(alpha))
webGLAttrs->setAlpha(jsAttrs->Get(alpha)->BooleanValue());
- v8::Handle<v8::String> depth = v8::String::New("depth");
+ v8::Handle<v8::String> depth = v8::String::NewSymbol("depth");
if (jsAttrs->Has(depth))
webGLAttrs->setDepth(jsAttrs->Get(depth)->BooleanValue());
- v8::Handle<v8::String> stencil = v8::String::New("stencil");
+ v8::Handle<v8::String> stencil = v8::String::NewSymbol("stencil");
if (jsAttrs->Has(stencil))
webGLAttrs->setStencil(jsAttrs->Get(stencil)->BooleanValue());
- v8::Handle<v8::String> antialias = v8::String::New("antialias");
+ v8::Handle<v8::String> antialias = v8::String::NewSymbol("antialias");
if (jsAttrs->Has(antialias))
webGLAttrs->setAntialias(jsAttrs->Get(antialias)->BooleanValue());
- v8::Handle<v8::String> premultipliedAlpha = v8::String::New("premultipliedAlpha");
+ v8::Handle<v8::String> premultipliedAlpha = v8::String::NewSymbol("premultipliedAlpha");
if (jsAttrs->Has(premultipliedAlpha))
webGLAttrs->setPremultipliedAlpha(jsAttrs->Get(premultipliedAlpha)->BooleanValue());
- v8::Handle<v8::String> preserveDrawingBuffer = v8::String::New("preserveDrawingBuffer");
+ v8::Handle<v8::String> preserveDrawingBuffer = v8::String::NewSymbol("preserveDrawingBuffer");
if (jsAttrs->Has(preserveDrawingBuffer))
webGLAttrs->setPreserveDrawingBuffer(jsAttrs->Get(preserveDrawingBuffer)->BooleanValue());
}
Modified: trunk/Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp (136588 => 136589)
--- trunk/Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp 2012-12-05 00:25:44 UTC (rev 136588)
+++ trunk/Source/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp 2012-12-05 00:27:50 UTC (rev 136589)
@@ -124,31 +124,31 @@
v8::Handle<v8::Value> value = args[0];
if (value->IsString())
- return v8::String::New("string");
+ return v8::String::NewSymbol("string");
if (value->IsArray())
- return v8::String::New("array");
+ return v8::String::NewSymbol("array");
if (value->IsBoolean())
- return v8::String::New("boolean");
+ return v8::String::NewSymbol("boolean");
if (value->IsNumber())
- return v8::String::New("number");
+ return v8::String::NewSymbol("number");
if (value->IsDate())
- return v8::String::New("date");
+ return v8::String::NewSymbol("date");
if (value->IsRegExp())
- return v8::String::New("regexp");
+ return v8::String::NewSymbol("regexp");
if (V8Node::HasInstance(value))
- return v8::String::New("node");
+ return v8::String::NewSymbol("node");
if (V8NodeList::HasInstance(value))
- return v8::String::New("array");
+ return v8::String::NewSymbol("array");
if (V8HTMLCollection::HasInstance(value))
- return v8::String::New("array");
+ return v8::String::NewSymbol("array");
if (V8Int8Array::HasInstance(value) || V8Int16Array::HasInstance(value) || V8Int32Array::HasInstance(value))
- return v8::String::New("array");
+ return v8::String::NewSymbol("array");
if (V8Uint8Array::HasInstance(value) || V8Uint16Array::HasInstance(value) || V8Uint32Array::HasInstance(value))
- return v8::String::New("array");
+ return v8::String::NewSymbol("array");
if (V8Float32Array::HasInstance(value) || V8Float64Array::HasInstance(value))
- return v8::String::New("array");
+ return v8::String::NewSymbol("array");
if (V8Uint8ClampedArray::HasInstance(value))
- return v8::String::New("array");
+ return v8::String::NewSymbol("array");
return v8::Undefined();
}
@@ -168,26 +168,26 @@
int columnNumber = function->GetScriptColumnNumber();
v8::Local<v8::Object> location = v8::Object::New();
- location->Set(v8::String::New("lineNumber"), v8Integer(lineNumber, args.GetIsolate()));
- location->Set(v8::String::New("columnNumber"), v8Integer(columnNumber, args.GetIsolate()));
- location->Set(v8::String::New("scriptId"), function->GetScriptId()->ToString());
+ location->Set(v8::String::NewSymbol("lineNumber"), v8Integer(lineNumber, args.GetIsolate()));
+ location->Set(v8::String::NewSymbol("columnNumber"), v8Integer(columnNumber, args.GetIsolate()));
+ location->Set(v8::String::NewSymbol("scriptId"), function->GetScriptId()->ToString());
v8::Local<v8::Object> result = v8::Object::New();
- result->Set(v8::String::New("location"), location);
+ result->Set(v8::String::NewSymbol("location"), location);
v8::Handle<v8::Value> name = function->GetName();
if (name->IsString() && v8::Handle<v8::String>::Cast(name)->Length())
- result->Set(v8::String::New("name"), name);
+ result->Set(v8::String::NewSymbol("name"), name);
v8::Handle<v8::Value> inferredName = function->GetInferredName();
if (inferredName->IsString() && v8::Handle<v8::String>::Cast(inferredName)->Length())
- result->Set(v8::String::New("inferredName"), inferredName);
+ result->Set(v8::String::NewSymbol("inferredName"), inferredName);
InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder());
ScriptDebugServer& debugServer = host->scriptDebugServer();
v8::Handle<v8::Value> scopes = debugServer.functionScopes(function);
if (!scopes.IsEmpty() && scopes->IsArray())
- result->Set(v8::String::New("rawScopes"), scopes);
+ result->Set(v8::String::NewSymbol("rawScopes"), scopes);
return result;
}
@@ -232,8 +232,8 @@
}
ASSERT(!function.IsEmpty());
v8::Local<v8::Object> listenerEntry = v8::Object::New();
- listenerEntry->Set(v8::String::New("listener"), function);
- listenerEntry->Set(v8::String::New("useCapture"), v8::Boolean::New(listenerInfo.eventListenerVector[i].useCapture));
+ listenerEntry->Set(v8::String::NewSymbol("listener"), function);
+ listenerEntry->Set(v8::String::NewSymbol("useCapture"), v8::Boolean::New(listenerInfo.eventListenerVector[i].useCapture));
result->Set(v8::Number::New(outputIndex++), listenerEntry);
}
return result;
Modified: trunk/Source/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp (136588 => 136589)
--- trunk/Source/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp 2012-12-05 00:25:44 UTC (rev 136588)
+++ trunk/Source/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp 2012-12-05 00:27:50 UTC (rev 136589)
@@ -71,12 +71,12 @@
{
for (size_t i = 0; i < itemArray->Length(); ++i) {
v8::Local<v8::Object> item = v8::Local<v8::Object>::Cast(itemArray->Get(i));
- v8::Local<v8::Value> type = item->Get(v8::String::New("type"));
- v8::Local<v8::Value> id = item->Get(v8::String::New("id"));
- v8::Local<v8::Value> label = item->Get(v8::String::New("label"));
- v8::Local<v8::Value> enabled = item->Get(v8::String::New("enabled"));
- v8::Local<v8::Value> checked = item->Get(v8::String::New("checked"));
- v8::Local<v8::Value> subItems = item->Get(v8::String::New("subItems"));
+ v8::Local<v8::Value> type = item->Get(v8::String::NewSymbol("type"));
+ v8::Local<v8::Value> id = item->Get(v8::String::NewSymbol("id"));
+ v8::Local<v8::Value> label = item->Get(v8::String::NewSymbol("label"));
+ v8::Local<v8::Value> enabled = item->Get(v8::String::NewSymbol("enabled"));
+ v8::Local<v8::Value> checked = item->Get(v8::String::NewSymbol("checked"));
+ v8::Local<v8::Value> subItems = item->Get(v8::String::NewSymbol("subItems"));
if (!type->IsString())
continue;
String typeString = toWebCoreStringWithNullCheck(type);