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

Unified Diff: cc/base/switches.cc

Issue 69123002: Generic version of caching cc switches to avoid searching of switches on each function call (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/base/switches.cc
diff --git a/cc/base/switches.cc b/cc/base/switches.cc
index be4a2c55adfbcb22214a0a92439f59da8fd112e2..8cd9e82abded07ad20e119175f21b01695e95203 100644
--- a/cc/base/switches.cc
+++ b/cc/base/switches.cc
@@ -165,37 +165,47 @@ bool IsLCDTextEnabled() {
#endif
}
-namespace {
-bool CheckImplSidePaintingStatus() {
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+// impl side painting
danakj 2013/11/11 17:57:53 The variable is called impl_side_painting, so I do
+static bool implSidePaintingStatus;
danakj 2013/11/11 17:57:53 this is blink style, you want g_impl_side_painting
+// map-image flag
danakj 2013/11/11 17:57:53 same with this comment
+static bool mapImageStatus;
- if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting))
- return false;
- else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting))
- return true;
+static void InitializeCCSwitchesIfRequired() {
+ static bool has_initialized_ccswitches = false;
+ if (has_initialized_ccswitches)
+ return;
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ // impl-side painting
danakj 2013/11/11 17:57:53 // Impl-side painting. (capitals and punctuation
+ if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting)) {
+ implSidePaintingStatus = false;
+ } else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting)) {
+ implSidePaintingStatus = true;
+ } else {
#if defined(OS_ANDROID)
- return true;
+ implSidePaintingStatus = true;
#else
- return false;
+ implSidePaintingStatus = false;
#endif
+ }
+
+ // map-image flag
danakj 2013/11/11 17:57:53 // Map-image flag.
+ if (command_line.HasSwitch(cc::switches::kDisableMapImage))
+ mapImageStatus = false;
+ else if (command_line.HasSwitch(cc::switches::kEnableMapImage))
+ mapImageStatus = true;
+
+ has_initialized_ccswitches = true;
}
-} // namespace
bool IsImplSidePaintingEnabled() {
- static bool enabled = CheckImplSidePaintingStatus();
- return enabled;
+ InitializeCCSwitchesIfRequired();
+ return implSidePaintingStatus;
}
bool IsMapImageEnabled() {
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
-
- if (command_line.HasSwitch(cc::switches::kDisableMapImage))
- return false;
- else if (command_line.HasSwitch(cc::switches::kEnableMapImage))
- return true;
-
- return false;
+ InitializeCCSwitchesIfRequired();
+ return mapImageStatus;
}
} // namespace switches
« no previous file with comments | « AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698