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

Side by Side Diff: runtime/lib/integers.cc

Issue 13852044: Fix performance of parsing Mints. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/platform/c99_support_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/exceptions.h" 9 #include "vm/exceptions.h"
10 #include "vm/native_entry.h" 10 #include "vm/native_entry.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 if (value.IsOneByteString()) { 186 if (value.IsOneByteString()) {
187 // Quick conversion for unpadded integers in strings. 187 // Quick conversion for unpadded integers in strings.
188 const intptr_t len = value.Length(); 188 const intptr_t len = value.Length();
189 if (len > 0) { 189 if (len > 0) {
190 const char* cstr = value.ToCString(); 190 const char* cstr = value.ToCString();
191 ASSERT(cstr != NULL); 191 ASSERT(cstr != NULL);
192 // Dart differences from strtol: 192 // Dart differences from strtol:
193 // a) '+5' is not a valid integer (leading plus). 193 // a) '+5' is not a valid integer (leading plus).
194 if (cstr[0] != '+') { 194 if (cstr[0] != '+') {
195 char* p_end = NULL; 195 char* p_end = NULL;
196 const int64_t int_value = strtol(cstr, &p_end, 10); 196 const int64_t int_value = strtoll(cstr, &p_end, 10);
197 if (p_end == (cstr + len)) { 197 if (p_end == (cstr + len)) {
198 if ((Smi::kMinValue <= int_value) && (int_value <= Smi::kMaxValue)) { 198 if ((int_value != LLONG_MIN) && (int_value != LLONG_MAX)) {
199 return Smi::New(int_value); 199 return Integer::New(int_value);
200 } 200 }
201 } 201 }
202 } 202 }
203 } 203 }
204 } 204 }
205 205
206 Scanner scanner(value, Symbols::Empty()); 206 Scanner scanner(value, Symbols::Empty());
207 const Scanner::GrowableTokenStream& tokens = scanner.GetStream(); 207 const Scanner::GrowableTokenStream& tokens = scanner.GetStream();
208 String* int_string; 208 String* int_string;
209 bool is_positive; 209 bool is_positive;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 324
325 DEFINE_NATIVE_ENTRY(Bigint_bitNegate, 1) { 325 DEFINE_NATIVE_ENTRY(Bigint_bitNegate, 1) {
326 const Bigint& value = Bigint::CheckedHandle(arguments->NativeArgAt(0)); 326 const Bigint& value = Bigint::CheckedHandle(arguments->NativeArgAt(0));
327 const Bigint& result = Bigint::Handle(BigintOperations::BitNot(value)); 327 const Bigint& result = Bigint::Handle(BigintOperations::BitNot(value));
328 ASSERT(CheckInteger(value)); 328 ASSERT(CheckInteger(value));
329 ASSERT(CheckInteger(result)); 329 ASSERT(CheckInteger(result));
330 return result.AsValidInteger(); 330 return result.AsValidInteger();
331 } 331 }
332 332
333 } // namespace dart 333 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/platform/c99_support_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698