Chromium Code Reviews| Index: runtime/lib/double.cc |
| =================================================================== |
| --- runtime/lib/double.cc (revision 18079) |
| +++ runtime/lib/double.cc (working copy) |
| @@ -79,13 +79,12 @@ |
| args.SetAt(0, String::Handle(String::New(error_msg))); |
| Exceptions::ThrowByType(Exceptions::kUnsupported, args); |
| } |
| - if ((Smi::kMinValue <= val) && (val <= Smi::kMaxValue)) { |
| - return Smi::New(static_cast<intptr_t>(val)); |
| - } else if ((Mint::kMinValue <= val) && (val <= Mint::kMaxValue)) { |
| - return Mint::New(static_cast<int64_t>(val)); |
| - } else { |
| - return BigintOperations::NewFromDouble(val); |
| + const Bigint& big = Bigint::Handle(BigintOperations::NewFromDouble(val)); |
| + if (BigintOperations::FitsIntoSmi(big)) return BigintOperations::ToSmi(big); |
|
Vyacheslav Egorov (Google)
2013/02/05 17:30:28
This code is hard to read. Can you make it
if (.
srdjan
2013/02/05 18:04:08
Done.
|
| + if (BigintOperations::FitsIntoMint(big)) { |
| + return Mint::New(BigintOperations::ToMint(big)); |
| } |
| + return big.raw(); |
| } |
| DEFINE_NATIVE_ENTRY(Double_trunc_div, 2) { |