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

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

Issue 1011613004: [bindings] Split toUInt64 into fast inline vs slow non-inline code paths. (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') | no next file with comments »
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 73270d981dd48c399bd09c99e2e38445940aa3f8..69847658805361bcbb6cdca1ef169d84ce3daa8a 100644
--- a/Source/bindings/core/v8/V8Binding.h
+++ b/Source/bindings/core/v8/V8Binding.h
@@ -477,10 +477,23 @@ inline int64_t toInt64(v8::Handle<v8::Value> value, ExceptionState& exceptionSta
// Convert a value to a 64-bit integer assuming the conversion cannot fail.
int64_t toInt64(v8::Handle<v8::Value>);
+CORE_EXPORT uint64_t toUInt64Slow(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
+
// Convert a value to a 64-bit unsigned 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-unsigned-long-long
-CORE_EXPORT uint64_t toUInt64(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&);
+inline uint64_t toUInt64(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState)
+{
+ // Fast case. The value is a 32-bit unsigned integer.
+ if (value->IsUint32())
+ return value->Uint32Value();
+
+ if (value->IsInt32() && configuration == NormalConversion)
+ return value->Int32Value();
+
+ return toUInt64Slow(value, configuration, exceptionState);
+}
+
inline uint64_t toUInt64(v8::Handle<v8::Value> value, ExceptionState& exceptionState)
{
return toUInt64(value, NormalConversion, exceptionState);
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8Binding.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698