Browse Source

* 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'.

Bastien Guerry 14 years ago
parent
commit
58e351efbf
1 changed files with 17 additions and 14 deletions
  1. 17 14
      lisp/org-taskjuggler.el

+ 17 - 14
lisp/org-taskjuggler.el

@@ -399,20 +399,23 @@ a path to the current task."
   "Figure out if each task is a leaf by looking at it's level,
   "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
 and the level of its successor. If the successor is higher (ie
 deeper), then it's not a leaf."
 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))))))
-
-(defun org-taskjuggler-assign-resource-ids (resources &optional unique-ids)
+  (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)
   "Given a list of resources return the same list, assigning a
   "Given a list of resources return the same list, assigning a
 unique id to each resource."
 unique id to each resource."
   (cond
   (cond