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

Side by Side Diff: src/date.h

Issue 2726253002: [date] Add a cache for timezone names to DateCache (Closed)
Patch Set: Actually use the cache... Created 3 years, 9 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 | src/date.cc » ('j') | 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 V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project 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 #ifndef V8_DATE_H_ 5 #ifndef V8_DATE_H_
6 #define V8_DATE_H_ 6 #define V8_DATE_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/base/platform/platform.h" 9 #include "src/base/platform/platform.h"
10 #include "src/globals.h" 10 #include "src/globals.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 local_offset_ms_ = GetLocalOffsetFromOS(); 86 local_offset_ms_ = GetLocalOffsetFromOS();
87 } 87 }
88 return local_offset_ms_; 88 return local_offset_ms_;
89 } 89 }
90 90
91 91
92 const char* LocalTimezone(int64_t time_ms) { 92 const char* LocalTimezone(int64_t time_ms) {
93 if (time_ms < 0 || time_ms > kMaxEpochTimeInMs) { 93 if (time_ms < 0 || time_ms > kMaxEpochTimeInMs) {
94 time_ms = EquivalentTime(time_ms); 94 time_ms = EquivalentTime(time_ms);
95 } 95 }
96 return base::OS::LocalTimezone(static_cast<double>(time_ms), tz_cache_); 96 bool is_dst = DaylightSavingsOffsetInMs(time_ms) != 0;
97 const char** name = is_dst ? &dst_tz_name_ : &tz_name_;
jgruber 2017/03/03 08:09:57 Nit: Can you use plain 'const char* name' instead
Dan Ehrenberg 2017/03/03 12:57:44 I don't think so, because then I don't see how I c
jgruber 2017/03/03 13:02:34 Ah, gotcha. sgtm.
98 if (*name == nullptr) {
99 *name = base::OS::LocalTimezone(static_cast<double>(time_ms), tz_cache_);
100 }
101 return *name;
97 } 102 }
98 103
99 // ECMA 262 - 15.9.5.26 104 // ECMA 262 - 15.9.5.26
100 int TimezoneOffset(int64_t time_ms) { 105 int TimezoneOffset(int64_t time_ms) {
101 int64_t local_ms = ToLocal(time_ms); 106 int64_t local_ms = ToLocal(time_ms);
102 return static_cast<int>((time_ms - local_ms) / kMsPerMin); 107 return static_cast<int>((time_ms - local_ms) / kMsPerMin);
103 } 108 }
104 109
105 // ECMA 262 - 15.9.1.9 110 // ECMA 262 - 15.9.1.9
106 // LocalTime(t) = t + LocalTZA + DaylightSavingTA(t) 111 // LocalTime(t) = t + LocalTZA + DaylightSavingTA(t)
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 275
271 int local_offset_ms_; 276 int local_offset_ms_;
272 277
273 // Year/Month/Day cache. 278 // Year/Month/Day cache.
274 bool ymd_valid_; 279 bool ymd_valid_;
275 int ymd_days_; 280 int ymd_days_;
276 int ymd_year_; 281 int ymd_year_;
277 int ymd_month_; 282 int ymd_month_;
278 int ymd_day_; 283 int ymd_day_;
279 284
285 // Timezone name cache
286 const char* tz_name_;
287 const char* dst_tz_name_;
288
280 base::TimezoneCache* tz_cache_; 289 base::TimezoneCache* tz_cache_;
281 }; 290 };
282 291
283 } // namespace internal 292 } // namespace internal
284 } // namespace v8 293 } // namespace v8
285 294
286 #endif 295 #endif
OLDNEW
« no previous file with comments | « no previous file | src/date.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698