Index: src/v8conversions.h |
diff --git a/src/v8conversions.h b/src/v8conversions.h |
index 17c05065180996b6a51a478daf3d14c0e4dcdd2b..d3da9f8bb86db798e9ca5ad017a197b7bd5240d0 100644 |
--- a/src/v8conversions.h |
+++ b/src/v8conversions.h |
@@ -55,39 +55,26 @@ double StringToDouble(UnicodeCache* unicode_cache, |
// Converts a string into an integer. |
double StringToInt(UnicodeCache* unicode_cache, String* str, int radix); |
-inline bool TryNumberToSize(Isolate* isolate, |
- Object* number, size_t* result) { |
+// Converts a number into size_t. |
+inline size_t NumberToSize(Isolate* isolate, |
+ Object* number) { |
SealHandleScope shs(isolate); |
if (number->IsSmi()) { |
int value = Smi::cast(number)->value(); |
- ASSERT(Smi::kMaxValue <= std::numeric_limits<size_t>::max()); |
- if (value >= 0) { |
- *result = static_cast<size_t>(value); |
- return true; |
- } |
- return false; |
+ CHECK_GE(value, 0); |
+ ASSERT( |
+ static_cast<unsigned>(Smi::kMaxValue) |
+ <= std::numeric_limits<size_t>::max()); |
+ return static_cast<size_t>(value); |
} else { |
ASSERT(number->IsHeapNumber()); |
double value = HeapNumber::cast(number)->value(); |
- if (value >= 0 && |
- value <= std::numeric_limits<size_t>::max()) { |
- *result = static_cast<size_t>(value); |
- return true; |
- } else { |
- return false; |
- } |
+ CHECK(value >= 0 && |
+ value <= std::numeric_limits<size_t>::max()); |
+ return static_cast<size_t>(value); |
} |
} |
-// Converts a number into size_t. |
-inline size_t NumberToSize(Isolate* isolate, |
- Object* number) { |
- size_t result; |
- bool is_valid = TryNumberToSize(isolate, number, &result); |
- CHECK(is_valid); |
- return result; |
-} |
- |
} } // namespace v8::internal |
#endif // V8_V8CONVERSIONS_H_ |