Chromium Code Reviews| Index: Source/bindings/core/v8/V8Binding.h |
| diff --git a/Source/bindings/core/v8/V8Binding.h b/Source/bindings/core/v8/V8Binding.h |
| index abbd3fdcb5e710b26fa3e970e9fbc827d746710e..b705e352af6da2c6f64ec52952bacede1be60b82 100644 |
| --- a/Source/bindings/core/v8/V8Binding.h |
| +++ b/Source/bindings/core/v8/V8Binding.h |
| @@ -432,7 +432,29 @@ int32_t toInt32(v8::Handle<v8::Value>); |
| // Convert a value to a 32-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 |
| -uint32_t toUInt32(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&); |
| +uint32_t toUInt32Slow(v8::Handle<v8::Value>, IntegerConversionConfiguration, ExceptionState&); |
| +inline uint32_t toUInt32(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState) |
| +{ |
| + // Fast case. The value is already a 32-bit unsigned integer. |
| + if (value->IsUint32()) |
| + return value->Uint32Value(); |
| + |
| + // Fast case. The value is a 32-bit signed integer - possibly positive? |
| + if (value->IsInt32()) { |
| + int32_t result = value->Int32Value(); |
| + if (result >= 0) |
| + return result; |
| + if (configuration == EnforceRange) { |
|
Jens Widell
2015/02/23 11:41:56
I think in principle that we're inlining too much
|
| + exceptionState.throwTypeError("Value is outside the 'unsigned long' value range."); |
| + return 0; |
| + } |
| + if (configuration == Clamp) |
| + return clampTo<uint32_t>(result); |
| + return result; |
| + } |
| + return toUInt32Slow(value, configuration, exceptionState); |
| +} |
| + |
| inline uint32_t toUInt32(v8::Handle<v8::Value> value, ExceptionState& exceptionState) |
| { |
| return toUInt32(value, NormalConversion, exceptionState); |