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

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_linux.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/object.cc
===================================================================
--- vm/object.cc (revision 9601)
+++ vm/object.cc (working copy)
@@ -7682,16 +7682,18 @@
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);
- } else {
+ // We are not supposed to have integers represented as two byte or
+ // four byte strings.
+ ASSERT(str.IsOneByteString());
+ const OneByteString& onestr = OneByteString::Cast(str);
+ int64_t value;
+ if (!OS::StringToInteger(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);
}
« no previous file with comments | « no previous file | vm/os.h » ('j') | vm/os_linux.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698