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

Unified Diff: base/ios/ios_util.mm

Issue 2935973002: iOS: Cache the result of IsRunningOnIOS10OrLater() (Closed)
Patch Set: Moved the variable to the outer anonymous namespace Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/ios/ios_util.mm
diff --git a/base/ios/ios_util.mm b/base/ios/ios_util.mm
index 196d5ef90ae4d81b894c4c23b8d2b87b6e878696..6938410b998a9bd3880612693a592c8268834d7d 100644
--- a/base/ios/ios_util.mm
+++ b/base/ios/ios_util.mm
@@ -21,6 +21,9 @@ const int32_t* OSVersionAsArray() {
return digits;
}
+// Caches the result of IsRunningOnIOS10OrLater().
rohitrao (ping after 24h) 2017/06/14 01:10:13 We'll be adding IsRunningOnIOS11OrLater() shortly,
+enum { kUnknown, kIos9orEarlier, kIos10orLater } g_ios_version = kUnknown;
Eugene But (OOO till 7-30) 2017/06/14 00:59:48 Should we cache the result of OSVersionAsArray ins
rohitrao (ping after 24h) 2017/06/14 01:10:13 Can you clarify what issue might "show up again la
Eugene But (OOO till 7-30) 2017/06/14 01:31:53 Sorry, I meant IsRunningOnIOS11(12/13/etc..)OrLate
+
std::string* g_icudtl_path_override = nullptr;
} // namespace
@@ -29,7 +32,11 @@ namespace base {
namespace ios {
bool IsRunningOnIOS10OrLater() {
- return IsRunningOnOrLater(10, 0, 0);
+ if (g_ios_version == kUnknown) {
Eugene But (OOO till 7-30) 2017/06/14 00:59:48 This makes the function non-thread safe, which you
+ g_ios_version =
+ IsRunningOnOrLater(10, 0, 0) ? kIos10orLater : kIos9orEarlier;
+ }
+ return g_ios_version == kIos10orLater;
}
bool IsRunningOnOrLater(int32_t major, int32_t minor, int32_t bug_fix) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698