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

Side by Side Diff: base/ios/ios_util.mm

Issue 2935973002: iOS: Cache the result of IsRunningOnIOS10OrLater() (Closed)
Patch Set: Caching simplification 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/ios/ios_util.h" 5 #include "base/ios/ios_util.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 11 matching lines...) Expand all
22 } 22 }
23 23
24 std::string* g_icudtl_path_override = nullptr; 24 std::string* g_icudtl_path_override = nullptr;
25 25
26 } // namespace 26 } // namespace
27 27
28 namespace base { 28 namespace base {
29 namespace ios { 29 namespace ios {
30 30
31 bool IsRunningOnIOS10OrLater() { 31 bool IsRunningOnIOS10OrLater() {
32 return IsRunningOnOrLater(10, 0, 0); 32 static const bool is_running_on_or_later = IsRunningOnOrLater(10, 0, 0);
33 return is_running_on_or_later;
33 } 34 }
34 35
35 bool IsRunningOnIOS11OrLater() { 36 bool IsRunningOnIOS11OrLater() {
36 return IsRunningOnOrLater(11, 0, 0); 37 static const bool is_running_on_or_later = IsRunningOnOrLater(11, 0, 0);
38 return is_running_on_or_later;
37 } 39 }
38 40
39 bool IsRunningOnOrLater(int32_t major, int32_t minor, int32_t bug_fix) { 41 bool IsRunningOnOrLater(int32_t major, int32_t minor, int32_t bug_fix) {
40 static const int32_t* current_version = OSVersionAsArray(); 42 static const int32_t* current_version = OSVersionAsArray();
41 int32_t version[] = {major, minor, bug_fix}; 43 int32_t version[] = {major, minor, bug_fix};
42 for (size_t i = 0; i < arraysize(version); i++) { 44 for (size_t i = 0; i < arraysize(version); i++) {
43 if (current_version[i] != version[i]) 45 if (current_version[i] != version[i])
44 return current_version[i] > version[i]; 46 return current_version[i] > version[i];
45 } 47 }
46 return true; 48 return true;
(...skipping 11 matching lines...) Expand all
58 60
59 FilePath FilePathOfEmbeddedICU() { 61 FilePath FilePathOfEmbeddedICU() {
60 if (g_icudtl_path_override) { 62 if (g_icudtl_path_override) {
61 return FilePath(*g_icudtl_path_override); 63 return FilePath(*g_icudtl_path_override);
62 } 64 }
63 return FilePath(); 65 return FilePath();
64 } 66 }
65 67
66 } // namespace ios 68 } // namespace ios
67 } // namespace base 69 } // namespace base
OLDNEW
« 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