Skip to content

Commit

Permalink
Log some stuff. Also, max depth and use a hash for somewhat better pe…
Browse files Browse the repository at this point in the history
…rformance.
  • Loading branch information
Andersbakken committed Jan 12, 2017
1 parent 38b583c commit ca18152
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/rtags.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ca18152

Please sign in to comment.