From 2be5ed1d4a7d6f92111ec26d6b8233fde815e72c Mon Sep 17 00:00:00 2001 From: Matt Beshara Date: Mon, 6 Sep 2021 14:46:16 +1000 Subject: fix(3p/exwm): Use hash table to cache ‘exwm-workspace--client-p’ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit imported from https://github.com/ch11ng/exwm/pull/848 Change-Id: I2b5509649b6933b52ed5df7f7fad7f3720f5facd Reviewed-on: https://cl.tvl.fyi/c/depot/+/3560 Tested-by: BuildkiteCI Reviewed-by: tazjin --- third_party/exwm/exwm-workspace.el | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'third_party/exwm') diff --git a/third_party/exwm/exwm-workspace.el b/third_party/exwm/exwm-workspace.el index cff17f3a113a..c1de5da9a391 100644 --- a/third_party/exwm/exwm-workspace.el +++ b/third_party/exwm/exwm-workspace.el @@ -165,10 +165,19 @@ NIL if FRAME is not a workspace" "Return t if FRAME is a workspace." (memq frame exwm-workspace--list)) +(defvar exwm--client-p-hash-table + (make-hash-table :test 'eq :weakness 'key)) + (defsubst exwm-workspace--client-p (&optional frame) "Return non-nil if FRAME is an emacsclient frame." - (or (frame-parameter frame 'client) - (not (display-graphic-p frame)))) + (let* ((frame (or frame (selected-frame))) + (cached-value (gethash frame exwm--client-p-hash-table 'absent))) + (if (eq cached-value 'absent) + (puthash frame + (or (frame-parameter frame 'client) + (not (display-graphic-p frame))) + exwm--client-p-hash-table) + cached-value))) (defvar exwm-workspace--switch-map nil "Keymap used for interactively selecting workspace.") -- cgit 1.4.1