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

Side by Side Diff: runtime/vm/flags.cc

Issue 1462953002: VM: Make more globals constant where easily possible. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove unnecessary const_cast Created 5 years, 1 month 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
« no previous file with comments | « runtime/bin/vmservice_impl.cc ('k') | runtime/vm/globals.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/flags.h" 5 #include "vm/flags.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/json_stream.h" 8 #include "vm/json_stream.h"
9 #include "vm/os.h" 9 #include "vm/os.h"
10 10
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 while ((*equals != '\0') && (*equals != '=')) { 281 while ((*equals != '\0') && (*equals != '=')) {
282 equals++; 282 equals++;
283 } 283 }
284 284
285 const char* argument = NULL; 285 const char* argument = NULL;
286 286
287 // Determine if this is an option argument. 287 // Determine if this is an option argument.
288 if (*equals != '=') { 288 if (*equals != '=') {
289 // No explicit option argument. Determine if there is a "no_" prefix 289 // No explicit option argument. Determine if there is a "no_" prefix
290 // preceding the name. 290 // preceding the name.
291 const char* kNo1Prefix = "no_"; 291 const char* const kNo1Prefix = "no_";
292 const char* kNo2Prefix = "no-"; 292 const char* const kNo2Prefix = "no-";
293 const intptr_t kNo1PrefixLen = strlen(kNo1Prefix); 293 const intptr_t kNo1PrefixLen = strlen(kNo1Prefix);
294 const intptr_t kNo2PrefixLen = strlen(kNo2Prefix); 294 const intptr_t kNo2PrefixLen = strlen(kNo2Prefix);
295 if (strncmp(option, kNo1Prefix, kNo1PrefixLen) == 0) { 295 if (strncmp(option, kNo1Prefix, kNo1PrefixLen) == 0) {
296 option += kNo1PrefixLen; // Skip the "no_" when looking up the name. 296 option += kNo1PrefixLen; // Skip the "no_" when looking up the name.
297 argument = "false"; 297 argument = "false";
298 } else if (strncmp(option, kNo2Prefix, kNo2PrefixLen) == 0) { 298 } else if (strncmp(option, kNo2Prefix, kNo2PrefixLen) == 0) {
299 option += kNo2PrefixLen; // Skip the "no-" when looking up the name. 299 option += kNo2PrefixLen; // Skip the "no-" when looking up the name.
300 argument = "false"; 300 argument = "false";
301 } else { 301 } else {
302 argument = "true"; 302 argument = "true";
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 352
353 353
354 bool Flags::ProcessCommandLineFlags(int number_of_vm_flags, 354 bool Flags::ProcessCommandLineFlags(int number_of_vm_flags,
355 const char** vm_flags) { 355 const char** vm_flags) {
356 if (initialized_) { 356 if (initialized_) {
357 return false; 357 return false;
358 } 358 }
359 359
360 qsort(flags_, num_flags_, sizeof flags_[0], CompareFlagNames); 360 qsort(flags_, num_flags_, sizeof flags_[0], CompareFlagNames);
361 361
362 const char* kPrefix = "--"; 362 const char* const kPrefix = "--";
363 const intptr_t kPrefixLen = strlen(kPrefix); 363 const intptr_t kPrefixLen = strlen(kPrefix);
364 364
365 int i = 0; 365 int i = 0;
366 while ((i < number_of_vm_flags) && 366 while ((i < number_of_vm_flags) &&
367 IsValidFlag(vm_flags[i], kPrefix, kPrefixLen)) { 367 IsValidFlag(vm_flags[i], kPrefix, kPrefixLen)) {
368 const char* option = vm_flags[i] + kPrefixLen; 368 const char* option = vm_flags[i] + kPrefixLen;
369 Parse(option); 369 Parse(option);
370 i++; 370 i++;
371 } 371 }
372 372
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 void Flags::PrintJSON(JSONStream* js) { 464 void Flags::PrintJSON(JSONStream* js) {
465 JSONObject jsobj(js); 465 JSONObject jsobj(js);
466 jsobj.AddProperty("type", "FlagList"); 466 jsobj.AddProperty("type", "FlagList");
467 JSONArray jsarr(&jsobj, "flags"); 467 JSONArray jsarr(&jsobj, "flags");
468 for (intptr_t i = 0; i < num_flags_; ++i) { 468 for (intptr_t i = 0; i < num_flags_; ++i) {
469 PrintFlagToJSONArray(&jsarr, flags_[i]); 469 PrintFlagToJSONArray(&jsarr, flags_[i]);
470 } 470 }
471 } 471 }
472 472
473 } // namespace dart 473 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/vmservice_impl.cc ('k') | runtime/vm/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698