Index: src/runtime.cc |
=================================================================== |
--- src/runtime.cc (revision 3939) |
+++ src/runtime.cc (working copy) |
@@ -4152,10 +4152,13 @@ |
NoHandleAllocation ha; |
ASSERT(args.length() == 1); |
- Object* obj = args[0]; |
- if (obj->IsSmi()) return obj; |
- CONVERT_DOUBLE_CHECKED(number, obj); |
- return Heap::NumberFromDouble(DoubleToInteger(number)); |
+ CONVERT_DOUBLE_CHECKED(number, args[0]); |
+ |
+ // We do not include 0 so that we didn't have to treat +0 / -0 cases. |
Mads Ager (chromium)
2010/02/25 15:11:03
didn't -> don't
Oleg Eterevsky
2010/02/25 15:30:43
Done.
|
+ if (number > 0 && number <= Smi::kMaxValue) |
Mads Ager (chromium)
2010/02/25 15:11:03
Please use braces around both the if and the else
Oleg Eterevsky
2010/02/25 15:30:43
Done.
|
+ return Smi::FromInt(static_cast<int>(number)); |
+ else |
+ return Heap::NumberFromDouble(DoubleToInteger(number)); |
} |
@@ -4164,7 +4167,6 @@ |
ASSERT(args.length() == 1); |
Object* obj = args[0]; |
Mads Ager (chromium)
2010/02/25 15:11:03
Just use args[0] in the CONVERT_NUMBER_CHECKED bel
Oleg Eterevsky
2010/02/25 15:30:43
Done.
|
- if (obj->IsSmi() && Smi::cast(obj)->value() >= 0) return obj; |
CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, obj); |
return Heap::NumberFromUint32(number); |
} |
@@ -4174,10 +4176,11 @@ |
NoHandleAllocation ha; |
ASSERT(args.length() == 1); |
- Object* obj = args[0]; |
- if (obj->IsSmi()) return obj; |
- CONVERT_DOUBLE_CHECKED(number, obj); |
- return Heap::NumberFromInt32(DoubleToInt32(number)); |
+ CONVERT_DOUBLE_CHECKED(number, args[0]); |
+ if (number > 0 && number <= Smi::kMaxValue) |
Mads Ager (chromium)
2010/02/25 15:11:03
Please use braces here as well. Repeat the commen
Oleg Eterevsky
2010/02/25 15:30:43
Done.
|
+ return Smi::FromInt(static_cast<int>(number)); |
+ else |
+ return Heap::NumberFromInt32(DoubleToInt32(number)); |
} |