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

Unified Diff: vm/os_macos.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
« vm/os_linux.cc ('K') | « vm/os_linux.cc ('k') | vm/os_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/os_macos.cc
===================================================================
--- vm/os_macos.cc (revision 9601)
+++ vm/os_macos.cc (working copy)
@@ -136,6 +136,29 @@
}
+bool OS::StringToInteger(const char* str, int64_t* value) {
+ ASSERT(str != NULL && strlen(str) > 0 && value != NULL);
+ bool negative_value = false;
+ int32_t base = 10;
+ if (str[0] == '-') {
+ negative_value = true;
+ str += 1;
+ }
+ if ((str[0] == '0') && (str[1] == 'x' || str[1] == 'X') && (str[2] != '\0')) {
+ base = 16;
+ }
+ errno = 0;
+ *value = strtoll(str, NULL, base);
+ if (errno == 0) {
+ if (negative_value) {
+ *value = -(*value);
+ }
+ return true;
+ }
+ return false;
+}
+
+
void OS::PrintErr(const char* format, ...) {
va_list args;
va_start(args, format);
« vm/os_linux.cc ('K') | « vm/os_linux.cc ('k') | vm/os_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698