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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « vm/os.h ('k') | vm/os_macos.cc » ('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/os.h" 5 #include "vm/os.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <limits.h> 8 #include <limits.h>
9 #include <time.h> 9 #include <time.h>
10 #include <sys/resource.h> 10 #include <sys/resource.h>
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 int OS::VSNPrint(char* str, size_t size, const char* format, va_list args) { 155 int OS::VSNPrint(char* str, size_t size, const char* format, va_list args) {
156 int retval = vsnprintf(str, size, format, args); 156 int retval = vsnprintf(str, size, format, args);
157 if (retval < 0) { 157 if (retval < 0) {
158 FATAL1("Fatal error in OS::VSNPrint with format '%s'", format); 158 FATAL1("Fatal error in OS::VSNPrint with format '%s'", format);
159 } 159 }
160 return retval; 160 return retval;
161 } 161 }
162 162
163 163
164 bool OS::StringToInteger(const char* str, int64_t* value) {
165 ASSERT(str != NULL && strlen(str) > 0 && value != NULL);
166 bool negative_value = false;
167 int32_t base = 10;
168 if (str[0] == '-') {
169 negative_value = true;
170 str += 1;
171 }
172 if ((str[0] == '0') && (str[1] == 'x' || str[1] == 'X') && (str[2] != '\0')) {
173 base = 16;
174 }
175 errno = 0;
176 *value = strtoll(str, NULL, base);
sra1 2012/07/12 20:12:15 There is a bug here with the minimum value. Since
siva 2012/07/16 19:45:47 Addressed this in a new CL. On 2012/07/12 20:12:1
177 if (errno == 0) {
178 if (negative_value) {
179 *value = -(*value);
180 }
181 return true;
182 }
183 return false;
184 }
185
186
164 void OS::PrintErr(const char* format, ...) { 187 void OS::PrintErr(const char* format, ...) {
165 va_list args; 188 va_list args;
166 va_start(args, format); 189 va_start(args, format);
167 VFPrint(stderr, format, args); 190 VFPrint(stderr, format, args);
168 va_end(args); 191 va_end(args);
169 } 192 }
170 193
171 194
172 void OS::InitOnce() { 195 void OS::InitOnce() {
173 // TODO(5411554): For now we check that initonce is called only once, 196 // TODO(5411554): For now we check that initonce is called only once,
(...skipping 12 matching lines...) Expand all
186 void OS::Abort() { 209 void OS::Abort() {
187 abort(); 210 abort();
188 } 211 }
189 212
190 213
191 void OS::Exit(int code) { 214 void OS::Exit(int code) {
192 exit(code); 215 exit(code);
193 } 216 }
194 217
195 } // namespace dart 218 } // namespace dart
OLDNEW
« no previous file with comments | « vm/os.h ('k') | vm/os_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698