gn: Employ the same INSERT_VARIABLE macro trick for switches.cc

This applies the macro trick used in variables.cc to clean up
GetSwitches() function.

BUG=None
R=brettw@chromium.org

Review URL: https://codereview.chromium.org/778513003

Cr-Original-Commit-Position: refs/heads/master@{#306691}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: d00cdf71c4e5ab4aa73cfa5f251a526e60cc2aba
diff --git a/tools/gn/switches.cc b/tools/gn/switches.cc
index 93c7f98..5e383e1 100644
--- a/tools/gn/switches.cc
+++ b/tools/gn/switches.cc
@@ -163,6 +163,8 @@
 // immediately if this switch is used.
 const char kVersion_Help[] = "";
 
+// -----------------------------------------------------------------------------
+
 SwitchInfo::SwitchInfo()
     : short_help(""),
       long_help("") {
@@ -173,23 +175,26 @@
       long_help(long_help) {
 }
 
-const SwitchInfoMap& GetSwitches() {
-  static SwitchInfoMap* switches = NULL;
-  if (!switches) {
-    switches = new SwitchInfoMap;
+#define INSERT_VARIABLE(var) \
+    info_map[k##var] = SwitchInfo(k##var##_HelpShort, k##var##_Help);
 
-    (*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);
+const SwitchInfoMap& GetSwitches() {
+  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
diff --git a/tools/gn/variables.cc b/tools/gn/variables.cc
index 102d651..4b0c514 100644
--- a/tools/gn/variables.cc
+++ b/tools/gn/variables.cc
@@ -960,8 +960,8 @@
 // -----------------------------------------------------------------------------
 
 VariableInfo::VariableInfo()
-    : help_short(NULL),
-      help(NULL) {
+    : help_short(""),
+      help("") {
 }
 
 VariableInfo::VariableInfo(const char* in_help_short, const char* in_help)