diff options
author | Matt Beshara <m@mfa.pw> | 2021-09-06T04·46+1000 |
---|---|---|
committer | tazjin <mail@tazj.in> | 2021-09-16T01·18+0000 |
commit | 2be5ed1d4a7d6f92111ec26d6b8233fde815e72c (patch) | |
tree | ef0cfaf41ce069e59d43154e78fdcca88596ba25 /third_party | |
parent | d0f7c85eb68041711d29c9d888ab995b12b0daa0 (diff) |
fix(3p/exwm): Use hash table to cache ‘exwm-workspace--client-p’ r/2872
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 <mail@tazj.in>
Diffstat (limited to 'third_party')
-rw-r--r-- | third_party/exwm/exwm-workspace.el | 13 |
1 files changed, 11 insertions, 2 deletions
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.") |