Commits

Peter Szilagyi  committed 4df2c25

provisional fix for slow Omake.Ring.sort-pending reported by nchapman

  • Participants
  • Parent commits d0aae86

Comments (0)

Files changed (1)

File elisp/omake/omake-ring.el

          (current-file (when current-file (expand-file-name current-file)))
          (current-partner (when current-file (Omake.File.partner current-file)))
          (default-dir (expand-file-name (Filename.default-directory)))
-         (f (lambda (acc e)
+
+         ;; acc
+         (same)
+         (partner)
+         (dir)
+         (other)
+
+         (f (lambda (e)
               (let* ((err-file (expand-file-name (Omake.Error.fullpath e)))
                      (err-partner (Omake.File.partner err-file))
                      (err-dir (Filename.directory-of err-file)))
-                (destructuring-bind (same partner dir other) acc
-                  (cond
-                   ((and current-file (equal current-file err-file))
-                    (list (cons e same) partner dir other))
-                   ((and current-partner (equal current-partner err-partner))
-                    (list same (cons e partner) dir other))
-                   ((equal default-dir err-dir)
-                    (list same partner (cons e dir) other))
-                   (t (list same partner dir (cons e other))))))))
-         (pending
-          (apply 'append
-                 (mapcar 'reverse
-                         (reduce f pending
-                                 :initial-value (list nil nil nil nil))))))
+                (cond ((and current-file (equal current-file err-file))
+                       (push e same))
+                      ((and current-partner (equal current-partner err-partner))
+                       (push e partner))
+                      ((equal default-dir err-dir)
+                       (push dir e))
+                      (t (push e other))))))
+         (pending (progn (mapc f pending)
+                         (revappend same
+                                    (revappend partner
+                                               (revappend dir
+                                                          (reverse other)))))))
     (Omake.Ring.create :current current :pending pending :visited visited)))
 
 (provide 'omake-ring)