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

Unified Diff: vm/os_linux.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.h ('K') | « vm/os.h ('k') | vm/os_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/os_linux.cc
===================================================================
--- vm/os_linux.cc (revision 9558)
+++ vm/os_linux.cc (working copy)
@@ -161,6 +161,30 @@
}
+bool OS::Strtoll(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 ((strlen(str) > 2) && (str[0] == '0') &&
sra1 2012/07/11 21:46:43 strlen scan not necessary since the conditions gua
siva 2012/07/12 18:28:23 Done.
+ (str[1] == 'x' || str[1] == 'X')) {
+ base = 16;
+ }
+ errno = 0;
+ *value = strtoll(str, NULL, base);
sra1 2012/07/11 21:46:43 You should pass in &endptr and verify endptr != st
siva 2012/07/12 18:28:23 I am not sure I understand the value of this addit
sra1 2012/07/12 20:12:15 You don't get ERANGE or EINVAL for trailing junk.
siva 2012/07/16 19:45:47 Good point, I have addressed this in a different C
+ 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.h ('K') | « vm/os.h ('k') | vm/os_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698