* org-taskjuggler.el (org-taskjuggler-compute-task-leafiness):

(org-taskjuggler-assign-resource-ids): Replace recursive
implementation with an iterative one.

That way we can avoid to have ask users to increase
`max-lisp-eval-depth'.
This commit is contained in:
Bastien Guerry 2011-03-17 09:52:01 +01:00
parent 8b1260aa08
commit 58e351efbf
1 changed files with 16 additions and 13 deletions

View File

@ -399,20 +399,23 @@ a path to the current task."
"Figure out if each task is a leaf by looking at it's level,
and the level of its successor. If the successor is higher (ie
deeper), then it's not a leaf."
(cond
((null tasks) nil)
;; if a task has no successors it is a leaf
((null (car (cdr tasks)))
(cons (cons (cons "leaf-node" t) (car tasks))
(org-taskjuggler-compute-task-leafiness (cdr tasks))))
;; if the successor has a lower level than task it is a leaf
((<= (cdr (assoc "level" (car (cdr tasks)))) (cdr (assoc "level" (car tasks))))
(cons (cons (cons "leaf-node" t) (car tasks))
(org-taskjuggler-compute-task-leafiness (cdr tasks))))
;; otherwise examine the rest of the tasks
(t (cons (car tasks) (org-taskjuggler-compute-task-leafiness (cdr tasks))))))
(let (new-list)
(while (car tasks)
(let ((task (car tasks))
(successor (car (cdr tasks))))
(cond
;; if a task has no successors it is a leaf
((null successor)
(push (cons (cons "leaf-node" t) task) new-list))
;; if the successor has a lower level than task it is a leaf
((<= (cdr (assoc "level" successor)) (cdr (assoc "level" task)))
(push (cons (cons "leaf-node" t) task) new-list))
;; otherwise examine the rest of the tasks
(t (push task new-list))))
(setq tasks (cdr tasks)))
(nreverse new-list)))
(defun org-taskjuggler-assign-resource-ids (resources &optional unique-ids)
(defun org-taskjuggler-assign-resource-ids (resources)
"Given a list of resources return the same list, assigning a
unique id to each resource."
(cond