Chromium Code Reviews| Index: tools/gn/switches.cc |
| diff --git a/tools/gn/switches.cc b/tools/gn/switches.cc |
| index 93c7f9870c38fe6ee2b899b2d64e7fc0c2a8637f..1860f569ceb25b6638d52b528a035b0e1c955043 100644 |
| --- a/tools/gn/switches.cc |
| +++ b/tools/gn/switches.cc |
| @@ -163,9 +163,11 @@ const char kVersion_HelpShort[] = |
| // immediately if this switch is used. |
| const char kVersion_Help[] = ""; |
| +// ----------------------------------------------------------------------------- |
| + |
| SwitchInfo::SwitchInfo() |
| - : short_help(""), |
| - long_help("") { |
| + : short_help(NULL), |
|
brettw
2014/12/03 17:57:33
I'm not sure we want to change this. I want them t
tfarina
2014/12/03 20:56:23
Done.
|
| + long_help(NULL) { |
| } |
| SwitchInfo::SwitchInfo(const char* short_help, const char* long_help) |
| @@ -173,23 +175,26 @@ SwitchInfo::SwitchInfo(const char* short_help, const char* long_help) |
| long_help(long_help) { |
| } |
| +#define INSERT_VARIABLE(var) \ |
| + info_map[k##var] = SwitchInfo(k##var##_HelpShort, k##var##_Help); |
| + |
| const SwitchInfoMap& GetSwitches() { |
| - static SwitchInfoMap* switches = NULL; |
| - if (!switches) { |
| - switches = new SwitchInfoMap; |
| - |
| - (*switches)[kArgs] = SwitchInfo(kArgs_HelpShort, kArgs_Help); |
| - (*switches)[kColor] = SwitchInfo(kColor_HelpShort, kColor_Help); |
| - (*switches)[kDotfile] = SwitchInfo(kDotfile_HelpShort, kDotfile_Help); |
| - (*switches)[kNoColor] = SwitchInfo(kNoColor_HelpShort, kNoColor_Help); |
| - (*switches)[kRoot] = SwitchInfo(kRoot_HelpShort, kRoot_Help); |
| - (*switches)[kQuiet] = SwitchInfo(kQuiet_HelpShort, kQuiet_Help); |
| - (*switches)[kTime] = SwitchInfo(kTime_HelpShort, kTime_Help); |
| - (*switches)[kTracelog] = SwitchInfo(kTracelog_HelpShort, kTracelog_Help); |
| - (*switches)[kVerbose] = SwitchInfo(kVerbose_HelpShort, kVerbose_Help); |
| - (*switches)[kVersion] = SwitchInfo(kVersion_HelpShort, kVersion_Help); |
| + static SwitchInfoMap info_map; |
| + if (info_map.empty()) { |
| + INSERT_VARIABLE(Args) |
| + INSERT_VARIABLE(Color) |
| + INSERT_VARIABLE(Dotfile) |
| + INSERT_VARIABLE(NoColor) |
| + INSERT_VARIABLE(Root) |
| + INSERT_VARIABLE(Quiet) |
| + INSERT_VARIABLE(Time) |
| + INSERT_VARIABLE(Tracelog) |
| + INSERT_VARIABLE(Verbose) |
| + INSERT_VARIABLE(Version) |
| } |
| - return *switches; |
| + return info_map; |
| } |
| +#undef INSERT_VARIABLE |
| + |
| } // namespace switches |