From ca181529aeea6554a4f65343e99bc51425f0ae34 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 11 Jan 2017 22:35:40 -0800 Subject: [PATCH] Log some stuff. Also, max depth and use a hash for somewhat better performance. --- src/rtags.el | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/rtags.el b/src/rtags.el index fecef0c61..3b344f3a5 100644 --- a/src/rtags.el +++ b/src/rtags.el @@ -1649,29 +1649,36 @@ instead of file from `current-buffer'. (goto-char (point-max)) (forward-line 1))))) -(defun rtags-references-tree-expand-all () - (interactive) +(defun rtags-references-tree-expand-all (&optional maxdepth) + (interactive "p") + (unless (integerp maxdepth) + (setq maxdepth nil)) (rtags-references-tree-collapse-all) (goto-char (point-min)) - (let ((seen)) + (let ((seen (make-hash-table :test 'equal)) roots (done 0)) (save-excursion (while (not (eobp)) - (add-to-list 'seen (car (rtags-references-tree-current-location))) + (puthash (car (rtags-references-tree-current-location)) t seen) (if (= (point-at-eol) (point-max)) (goto-char (point-max)) (forward-line 1)))) (save-excursion + (setq roots (float (hash-table-count seen))) (while (not (eobp)) (let ((loc (rtags-references-tree-current-location))) (cond ((= (cdr loc) 0) - (rtags-references-tree-expand-current)) - ((not (member (car loc) seen)) - (push (car loc) seen) - (rtags-references-tree-expand-current)) + (message "Expand all: %g%% %d/%d" (* (/ done roots) 100.0) done roots) + (rtags-references-tree-expand-current) + (incf done)) + ((not (gethash (car loc) seen)) + (when (or (not maxdepth) (< (cdr loc) maxdepth)) + (puthash (car loc) t seen) + (rtags-references-tree-expand-current))) (t))) (if (= (point-at-eol) (point-max)) (goto-char (point-max)) - (forward-line 1)))))) + (forward-line 1)))) + (message "Expand all: 100%% %d/%d" done roots))) (defun rtags-file-from-location (location) (and location