From a6e33459b34499f368b1ee96c8d103ea5ef9bdee Mon Sep 17 00:00:00 2001 From: ueno Date: Sat, 19 Nov 2005 00:30:37 +0000 Subject: [PATCH] * riece-channel.el: Require 'riece-cache. (riece-find-channel): Increase priority of given channel name in riece-channel-cache. (riece-forget-channel): Remove given channel name from riece-channel-cache. (riece-get-channel): Register given channel name in riece-channel-cache (if it is being added to riece-channel-obarray.) * riece-server.el (riece-reset-process-buffer): Initialize riece-channel-cache. * riece-options.el (riece-channel-cache-max-size): New user option. * riece-misc.el (riece-get-channels-on-server): Get channel names from riece-channel-cache. * riece-globals.el (riece-channel-cache): New variable. --- lisp/ChangeLog | 23 ++++++++++++++++++----- lisp/riece-channel.el | 8 +++++++- lisp/riece-globals.el | 3 +++ lisp/riece-misc.el | 2 +- lisp/riece-options.el | 5 +++++ lisp/riece-server.el | 2 ++ lisp/riece-user.el | 4 +++- 7 files changed, 39 insertions(+), 8 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 044bdd4..a6b0767 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,20 @@ +2005-11-19 Daiki Ueno + + * riece-channel.el: Require 'riece-cache. + (riece-find-channel): Increase priority of given channel name in + riece-channel-cache. + (riece-forget-channel): Remove given channel name from + riece-channel-cache. + (riece-get-channel): Register given channel name in + riece-channel-cache (if it is being added to riece-channel-obarray.) + * riece-server.el (riece-reset-process-buffer): Initialize + riece-channel-cache. + * riece-options.el (riece-channel-cache-max-size): New user + option. + * riece-misc.el (riece-get-channels-on-server): Get channel names + from riece-channel-cache. + * riece-globals.el (riece-channel-cache): New variable. + 2005-11-18 Daiki Ueno * riece-cache.el: Renamed from riece-lru.el. @@ -10,18 +27,14 @@ (riece-forget-user): Remove given username from riece-user-lru. (riece-rename-user): Rename given username in riece-user-lru. (riece-get-user): Register given username in riece-user-lru (if - is being added to riece-user-obarray.) - + it is being added to riece-user-obarray.) * riece-server.el: Require 'riece-lru. (riece-reset-process-buffer): Initialize riece-user-lru. - * riece-options.el (riece-user-lru-max-size): New user option. * riece-misc.el: Require 'riece-lru. (riece-get-users-on-server): Get usernames from riece-user-lru. - * riece-globals.el (riece-user-lru): New variable. * COMPILE (riece-modules): Added riece-lru. - * riece-lru.el: New file. * riece-develop.el: New file. diff --git a/lisp/riece-channel.el b/lisp/riece-channel.el index 2536e5b..454725b 100644 --- a/lisp/riece-channel.el +++ b/lisp/riece-channel.el @@ -28,16 +28,19 @@ (require 'riece-globals) (require 'riece-identity) (require 'riece-mode) +(require 'riece-cache) ;;; Channel object: (defun riece-find-channel (name) "Get a channel object named NAME from the server buffer." + (riece-cache-get riece-channel-cache name) (let ((symbol (intern-soft (riece-identity-canonicalize-prefix name) riece-channel-obarray))) (if symbol (symbol-value symbol)))) (defun riece-forget-channel (name) + (riece-cache-delete riece-channel-cache name) (let ((symbol (intern-soft (riece-identity-canonicalize-prefix name) riece-channel-obarray))) (when symbol @@ -55,7 +58,10 @@ respectively." (let ((symbol (intern-soft (riece-identity-canonicalize-prefix name) riece-channel-obarray))) (if symbol - (symbol-value symbol) + (progn + (riece-cache-get riece-channel-cache name) + (symbol-value symbol)) + (riece-cache-set riece-channel-cache name name) (set (intern (riece-identity-canonicalize-prefix name) riece-channel-obarray) (riece-make-channel nil nil nil nil nil nil nil))))) diff --git a/lisp/riece-globals.el b/lisp/riece-globals.el index 348e155..670427b 100644 --- a/lisp/riece-globals.el +++ b/lisp/riece-globals.el @@ -131,6 +131,9 @@ Local to the server buffers.") (defvar riece-coding-system nil "Coding system for process I/O. Local to the server buffers.") +(defvar riece-channel-cache nil + "Cache of channel names. +Local to the server buffers.") (defvar riece-user-cache nil "Cache of usernames. Local to the server buffers.") diff --git a/lisp/riece-misc.el b/lisp/riece-misc.el index bc06db1..d0575a2 100644 --- a/lisp/riece-misc.el +++ b/lisp/riece-misc.el @@ -233,7 +233,7 @@ (setq identities (cons (riece-make-identity (symbol-name channel) server-name) identities))) - riece-channel-obarray) + (riece-cache-map-hash-obarray riece-channel-cache)) identities))) (defun riece-get-identities-on-server (server-name) diff --git a/lisp/riece-options.el b/lisp/riece-options.el index 1a0f37d..0f81403 100644 --- a/lisp/riece-options.el +++ b/lisp/riece-options.el @@ -253,6 +253,11 @@ way is to put Riece variables on .emacs or file loaded from there." :type 'integer :group 'riece-server) +(defcustom riece-channel-cache-max-size 512 + "Maximum size of cache of channel names." + :type 'integer + :group 'riece-server) + (defcustom riece-channel-buffer-mode t "When non-nil, Riece will display a channel buffer." :type 'boolean diff --git a/lisp/riece-server.el b/lisp/riece-server.el index 4a64df1..1788e0e 100644 --- a/lisp/riece-server.el +++ b/lisp/riece-server.el @@ -272,6 +272,8 @@ the `riece-server-keyword-map' variable." (make-local-variable 'riece-channel-obarray) (setq riece-channel-obarray (make-vector riece-channel-obarray-size 0)) (make-local-variable 'riece-coding-system) + (make-local-variable 'riece-channel-cache) + (setq riece-channel-cache (riece-make-cache riece-channel-cache-max-size)) (make-local-variable 'riece-user-cache) (setq riece-user-cache (riece-make-cache riece-user-cache-max-size)) (buffer-disable-undo) diff --git a/lisp/riece-user.el b/lisp/riece-user.el index 3af38da..8f50548 100644 --- a/lisp/riece-user.el +++ b/lisp/riece-user.el @@ -67,7 +67,9 @@ away status, respectively." (let ((symbol (intern-soft (riece-identity-canonicalize-prefix name) riece-user-obarray))) (if symbol - (symbol-value symbol) + (progn + (riece-cache-get riece-user-cache name) + (symbol-value symbol)) (riece-cache-set riece-user-cache name name) (set (intern (riece-identity-canonicalize-prefix name) riece-user-obarray) -- 1.7.10.4