|
|
067a6b |
From dd03c3a2fe0c87dc1823aad578f95e972aba50a9 Mon Sep 17 00:00:00 2001
|
|
|
067a6b |
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
|
|
067a6b |
Date: Thu, 27 Feb 2020 13:46:44 -0800
|
|
|
067a6b |
Subject: [PATCH 1/6] environment: reduce calls to g_time_zone_new_local()
|
|
|
067a6b |
|
|
|
067a6b |
Creating a new GTimeZone for the local timezone can be quite expensive if
|
|
|
067a6b |
done repeatedly. It requires an open(), mmap(), and parsing of
|
|
|
067a6b |
/etc/localtime.
|
|
|
067a6b |
|
|
|
067a6b |
This patch was provided by Florian, and I've tested it as far back as
|
|
|
067a6b |
3.28.4 to ensure that we are really reducing the number of open() calls
|
|
|
067a6b |
on the compositor thread.
|
|
|
067a6b |
|
|
|
067a6b |
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/1051
|
|
|
067a6b |
|
|
|
067a6b |
Signed-off-by: Christian Hergert <chergert@redhat.com>
|
|
|
067a6b |
---
|
|
|
067a6b |
js/ui/environment.js | 22 +++++++++++++++++++++-
|
|
|
067a6b |
1 file changed, 21 insertions(+), 1 deletion(-)
|
|
|
067a6b |
|
|
|
067a6b |
diff --git a/js/ui/environment.js b/js/ui/environment.js
|
|
|
067a6b |
index 719680f61..78a24f888 100644
|
|
|
067a6b |
--- a/js/ui/environment.js
|
|
|
067a6b |
+++ b/js/ui/environment.js
|
|
|
067a6b |
@@ -17,6 +17,9 @@ const Gtk = imports.gi.Gtk;
|
|
|
067a6b |
const Lang = imports.lang;
|
|
|
067a6b |
const Shell = imports.gi.Shell;
|
|
|
067a6b |
const St = imports.gi.St;
|
|
|
067a6b |
+const System = imports.system;
|
|
|
067a6b |
+
|
|
|
067a6b |
+let _localTimeZone = null;
|
|
|
067a6b |
|
|
|
067a6b |
// We can't import shell JS modules yet, because they may have
|
|
|
067a6b |
// variable initializations, etc, that depend on init() already having
|
|
|
067a6b |
@@ -116,9 +119,26 @@ function init() {
|
|
|
067a6b |
}
|
|
|
067a6b |
};
|
|
|
067a6b |
|
|
|
067a6b |
+ // Override to clear our own timezone cache as well
|
|
|
067a6b |
+ const origClearDateCaches = System.clearDateCaches;
|
|
|
067a6b |
+ System.clearDateCaches = function () {
|
|
|
067a6b |
+ _localTimeZone = null;
|
|
|
067a6b |
+ origClearDateCaches();
|
|
|
067a6b |
+ };
|
|
|
067a6b |
+
|
|
|
067a6b |
// Work around https://bugzilla.mozilla.org/show_bug.cgi?id=508783
|
|
|
067a6b |
Date.prototype.toLocaleFormat = function(format) {
|
|
|
067a6b |
- return Shell.util_format_date(format, this.getTime());
|
|
|
067a6b |
+ if (_localTimeZone === null)
|
|
|
067a6b |
+ _localTimeZone = GLib.TimeZone.new_local();
|
|
|
067a6b |
+
|
|
|
067a6b |
+ let dt = GLib.DateTime.new(_localTimeZone,
|
|
|
067a6b |
+ this.getYear(),
|
|
|
067a6b |
+ this.getMonth() + 1,
|
|
|
067a6b |
+ this.getDate(),
|
|
|
067a6b |
+ this.getHours(),
|
|
|
067a6b |
+ this.getMinutes(),
|
|
|
067a6b |
+ this.getSeconds());
|
|
|
067a6b |
+ return dt ? dt.format(format) : '';
|
|
|
067a6b |
};
|
|
|
067a6b |
|
|
|
067a6b |
let slowdownEnv = GLib.getenv('GNOME_SHELL_SLOWDOWN_FACTOR');
|
|
|
067a6b |
--
|
|
|
067a6b |
2.26.0
|
|
|
067a6b |
|