Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Unified Diff: Source/bindings/core/v8/V8Binding.h

Issue 1009143002: [bindings] Split toInt32 into fast inline and slower non-inline path. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8Binding.cpp » ('j') | Source/bindings/core/v8/V8Binding.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/V8Binding.h
diff --git a/Source/bindings/core/v8/V8Binding.h b/Source/bindings/core/v8/V8Binding.h
index 721c9a1167cc9edd9602e22d8084c1c1fefc4b8d..73270d981dd48c399bd09c99e2e38445940aa3f8 100644
--- a/Source/bindings/core/v8/V8Binding.h
+++ b/Source/bindings/core/v8/V8Binding.h
@@ -418,10 +418,20 @@ inline uint16_t toUInt16(v8::Handle<v8::Value> value, ExceptionState& exceptionS
// Convert a value to a 16-bit unsigned integer assuming the conversion cannot fail.
uint16_t toUInt16(v8::Handle<v8::Value>);
+
+CORE_EXPORT int32_t toInt32Slow(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
+
// Convert a value to a 32-bit signed integer. The conversion fails if the
// value cannot be converted to a number or the range violated per WebIDL:
// http://www.w3.org/TR/WebIDL/#es-long
-CORE_EXPORT int32_t toInt32(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
+inline int32_t toInt32(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState)
+{
+ // Fast case. The value is already a 32-bit integer.
+ if (value->IsInt32())
+ return value->Int32Value();
+ return toInt32Slow(value, configuration, exceptionState);
+}
+
inline int32_t toInt32(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
{
return toInt32(value, NormalConversion, exceptionState);
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8Binding.cpp » ('j') | Source/bindings/core/v8/V8Binding.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698