Index: vm/object.cc |
=================================================================== |
--- vm/object.cc (revision 9558) |
+++ vm/object.cc (working copy) |
@@ -7679,15 +7679,21 @@ |
RawInteger* Integer::New(const String& str, Heap::Space space) { |
- // TODO(iposva): If returning a big integer it will not necessarily be in the |
- // requested space. |
- const Bigint& big = Bigint::Handle(Bigint::New(str)); |
- if (BigintOperations::FitsIntoSmi(big)) { |
- return BigintOperations::ToSmi(big); |
- } else if (BigintOperations::FitsIntoMint(big)) { |
- return Mint::New(BigintOperations::ToMint(big), space); |
+ if (str.IsOneByteString()) { |
+ const OneByteString& onestr = OneByteString::Cast(str); |
+ int64_t value; |
+ if (!OS::Strtoll(onestr.ToCString(), &value)) { |
+ const Bigint& big = Bigint::Handle(Bigint::New(onestr, space)); |
+ ASSERT(!BigintOperations::FitsIntoSmi(big)); |
+ ASSERT(!BigintOperations::FitsIntoMint(big)); |
+ return big.raw(); |
+ } |
+ return Integer::New(value, space); |
} else { |
- return big.raw(); |
+ // We are not supposed to have integers represented as two byte or |
cshapiro
2012/07/11 22:11:02
Why isn't this just an ASSERT(str.IsOneByteString(
siva
2012/07/12 18:28:23
Done.
|
+ // four byte strings. |
+ UNREACHABLE(); |
+ return Integer::null(); |
} |
} |