Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Unified Diff: vm/object.cc

Issue 10703150: Don't create a Bigint object first for every integer while parsing the sources, instead first check… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | vm/os.h » ('j') | vm/os.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
}
}
« no previous file with comments | « no previous file | vm/os.h » ('j') | vm/os.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698