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

Unified 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, 10 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 | src/date.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/date.h
diff --git a/src/date.h b/src/date.h
index 0a3e91beb26589e1b5078e420bfe07a8b18ada25..9f081bb185593e02b5d9e543172f990b4f0d842b 100644
--- a/src/date.h
+++ b/src/date.h
@@ -93,7 +93,12 @@ class DateCache {
if (time_ms < 0 || time_ms > kMaxEpochTimeInMs) {
time_ms = EquivalentTime(time_ms);
}
- return base::OS::LocalTimezone(static_cast<double>(time_ms), tz_cache_);
+ bool is_dst = DaylightSavingsOffsetInMs(time_ms) != 0;
+ 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.
+ if (*name == nullptr) {
+ *name = base::OS::LocalTimezone(static_cast<double>(time_ms), tz_cache_);
+ }
+ return *name;
}
// ECMA 262 - 15.9.5.26
@@ -277,6 +282,10 @@ class DateCache {
int ymd_month_;
int ymd_day_;
+ // Timezone name cache
+ const char* tz_name_;
+ const char* dst_tz_name_;
+
base::TimezoneCache* tz_cache_;
};
« 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