From: hmurata Date: Wed, 23 Aug 2006 00:21:12 +0000 (+0000) Subject: (elmo-map-folder-update-locations): Rewrite with X-Git-Tag: wl-2_15_4~12 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=f894e0ccd683e14b47ddbe1422ce24db48159575;p=elisp%2Fwanderlust.git (elmo-map-folder-update-locations): Rewrite with hash table to test whether a location is exists. --- diff --git a/elmo/ChangeLog b/elmo/ChangeLog index 6ff3626..873baca 100644 --- a/elmo/ChangeLog +++ b/elmo/ChangeLog @@ -1,3 +1,8 @@ +2006-08-23 Hiroya Murata + + * elmo-map.el (elmo-map-folder-update-locations): Rewrite with + hash table to test whether a location is exists. + 2006-08-20 Yoichi NAKAYAMA * elmo-archive.el (elmo-folder-append-messages): Delete temp-dir diff --git a/elmo/elmo-map.el b/elmo/elmo-map.el index adac358..009f5a2 100644 --- a/elmo/elmo-map.el +++ b/elmo/elmo-map.el @@ -159,50 +159,35 @@ ;; A subroutine to make location-alist. ;; location-alist is existing location-alist. ;; locations is the newest locations. - (let* ((location-alist (elmo-map-folder-location-alist-internal folder)) - (locations-in-db (mapcar 'cdr location-alist)) - new-locs new-alist deleted-locs pair i) - (setq new-locs - (elmo-delete-if (function - (lambda (x) (member x locations-in-db))) - locations)) - (setq deleted-locs - (elmo-delete-if (function - (lambda (x) (member x locations))) - locations-in-db)) - (dolist (location deleted-locs) - (setq location-alist - (delq (setq pair - (elmo-get-hash-val - location - (elmo-map-folder-location-hash-internal - folder))) - location-alist)) - (when pair - (elmo-clear-hash-val (concat "#" (int-to-string (car pair))) - (elmo-map-folder-location-hash-internal - folder)) - (elmo-clear-hash-val location - (elmo-map-folder-location-hash-internal - folder)))) - (setq i (elmo-map-folder-number-max-internal folder)) - (dolist (location new-locs) - (setq i (1+ i)) - (elmo-map-folder-set-number-max-internal folder i) - (setq new-alist (cons (setq pair (cons i location)) new-alist)) - (setq new-alist (nreverse new-alist)) - (elmo-set-hash-val (concat "#" (int-to-string i)) - pair - (elmo-map-folder-location-hash-internal - folder)) - (elmo-set-hash-val location - pair - (elmo-map-folder-location-hash-internal - folder))) - (setq location-alist - (sort (nconc location-alist new-alist) - (lambda (x y) (< (car x) (car y))))) - (elmo-map-folder-set-location-alist-internal folder location-alist))) + (let ((location-hash (elmo-map-folder-location-hash-internal folder)) + (exists-hash (elmo-make-hash (length locations))) + (number (elmo-map-folder-number-max-internal folder)) + new-alist) + (dolist (location locations) + (if (elmo-get-hash-val location location-hash) + (elmo-set-hash-val location t exists-hash) + (setq number (1+ number)) + (let ((pair (cons number location))) + (setq new-alist (cons pair new-alist)) + (elmo-set-hash-val (concat "#" (int-to-string number)) + pair + location-hash) + (elmo-set-hash-val location pair location-hash)))) + (elmo-map-folder-set-number-max-internal folder number) + (elmo-map-folder-set-location-alist-internal + folder + (nconc + (delq nil + (mapcar + (lambda (pair) + (if (elmo-get-hash-val (cdr pair) exists-hash) + pair + (elmo-clear-hash-val (concat "#" (int-to-string (car pair))) + location-hash) + (elmo-clear-hash-val (cdr pair) location-hash) + nil)) + (elmo-map-folder-location-alist-internal folder))) + (nreverse new-alist))))) (luna-define-method elmo-folder-open-internal ((folder elmo-map-folder)) (elmo-map-folder-location-setup