From 1d868013f382ee4a7069d5b1cf23e22acc86096e Mon Sep 17 00:00:00 2001 From: ueno Date: Fri, 18 Nov 2005 09:23:34 +0000 Subject: [PATCH] * riece-user.el: Require 'riece-lru. (riece-find-user): Increase priority of given username in riece-user-lru. (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.) * 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. --- lisp/COMPILE | 1 + lisp/ChangeLog | 18 ++++++++++++++++++ lisp/riece-globals.el | 3 +++ lisp/riece-lru.el | 5 +++-- lisp/riece-misc.el | 3 ++- lisp/riece-options.el | 5 +++++ lisp/riece-server.el | 3 +++ lisp/riece-user.el | 10 ++++++++-- 8 files changed, 43 insertions(+), 5 deletions(-) diff --git a/lisp/COMPILE b/lisp/COMPILE index 051a7d9..4e5ad0e 100644 --- a/lisp/COMPILE +++ b/lisp/COMPILE @@ -14,6 +14,7 @@ riece-addon-modules riece-addon riece-ruby + riece-lru riece-mode ;; riece-identity -+-> riece-channel diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9a2922d..4675df6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,23 @@ 2005-11-18 Daiki Ueno + * riece-user.el: Require 'riece-lru. + (riece-find-user): Increase priority of given username in + riece-user-lru. + (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.) + + * 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-globals.el b/lisp/riece-globals.el index 57f97fa..9629d5a 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-user-lru nil + "LRU cache of usernames. +Local to the server buffers.") ;;; Variables local to the channel buffers: (defvar riece-freeze nil diff --git a/lisp/riece-lru.el b/lisp/riece-lru.el index 138d88d..c7d0daa 100644 --- a/lisp/riece-lru.el +++ b/lisp/riece-lru.el @@ -74,12 +74,11 @@ (defun riece-lru-get-node (map key) (let ((symbol (intern-soft key (riece-lru-map-hash-obarray map))) - previous next first last node) + previous next last node) (when symbol (setq node (symbol-value symbol) previous (riece-lru-node-previous node) next (riece-lru-node-next node) - first (riece-lru-map-first map) last (riece-lru-map-last map)) (if previous (riece-lru-node-set-next previous next)) @@ -131,3 +130,5 @@ (riece-lru-node-set-next (riece-lru-map-last map) node) (riece-lru-node-set-previous node (riece-lru-map-last map)))) (riece-lru-map-set-last map node)))) + +(provide 'riece-lru) \ No newline at end of file diff --git a/lisp/riece-misc.el b/lisp/riece-misc.el index eb0de20..ebb9234 100644 --- a/lisp/riece-misc.el +++ b/lisp/riece-misc.el @@ -32,6 +32,7 @@ (require 'riece-server) (require 'riece-user) (require 'riece-mode) +(require 'riece-lru) (defun riece-get-buffer-create (name &optional init-major-mode) (let ((buffer (get-buffer name))) @@ -221,7 +222,7 @@ (setq identities (cons (riece-make-identity (symbol-name user) server-name) identities))) - riece-user-obarray) + (riece-lru-map-hash-obarray riece-user-lru)) identities))) (defun riece-get-channels-on-server (server-name) diff --git a/lisp/riece-options.el b/lisp/riece-options.el index 8330ff5..778f101 100644 --- a/lisp/riece-options.el +++ b/lisp/riece-options.el @@ -248,6 +248,11 @@ way is to put Riece variables on .emacs or file loaded from there." :type 'function :group 'riece-server) +(defcustom riece-user-lru-max-size 512 + "Maximum size of LRU cache of usernames." + :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 be1c8a7..4d8a1f3 100644 --- a/lisp/riece-server.el +++ b/lisp/riece-server.el @@ -29,6 +29,7 @@ (require 'riece-coding) ;riece-default-coding-system (require 'riece-identity) (require 'riece-compat) +(require 'riece-lru) (eval-and-compile (defvar riece-server-keyword-map @@ -271,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-user-lru) + (setq riece-user-lru (riece-make-lru riece-user-lru-max-size)) (buffer-disable-undo) (erase-buffer))) diff --git a/lisp/riece-user.el b/lisp/riece-user.el index 9ad4ee1..fb4b261 100644 --- a/lisp/riece-user.el +++ b/lisp/riece-user.el @@ -25,22 +25,27 @@ (require 'riece-identity) (require 'riece-mode) +(require 'riece-lru) ;;; User object: (defun riece-find-user (name) "Get a user object named NAME from the server buffer." + (riece-lru-get riece-user-lru name) (let ((symbol (intern-soft (riece-identity-canonicalize-prefix name) riece-user-obarray))) - (if symbol - (symbol-value symbol)))) + (if symbol + (symbol-value symbol)))) (defun riece-forget-user (name) + (riece-lru-delete riece-user-lru name) (let ((symbol (intern-soft (riece-identity-canonicalize-prefix name)))) (when symbol (makunbound symbol) (unintern (symbol-name symbol) riece-user-obarray)))) (defun riece-rename-user (old-name new-name) + (riece-lru-delete riece-user-lru old-name) + (riece-lru-set riece-user-lru new-name new-name) (unless (equal (riece-identity-canonicalize-prefix old-name) (riece-identity-canonicalize-prefix new-name)) (let ((symbol (intern-soft (riece-identity-canonicalize-prefix old-name) @@ -63,6 +68,7 @@ away status, respectively." riece-user-obarray))) (if symbol (symbol-value symbol) + (riece-lru-set riece-user-lru name name) (set (intern (riece-identity-canonicalize-prefix name) riece-user-obarray) (riece-make-user nil nil nil nil nil))))) -- 1.7.10.4