monnier pushed a commit to branch master
in repository elpa.
commit 153b45f03fc9015bf2ae29a71d3bc4f262be4864
Author: Teemu Likonen <[email protected]>
Date: Wed Feb 24 16:56:02 2010 +0000
Toteutetaan wcheck-combine-overlapping-areas järkevämmin
Poistetaan turha APPEND, joka edellisessä toteutuksessa kopioi joka
kerta listan uudelleen. Muutetaan se nopeammaksi CONSiksi, joka
täydentää samaa listaa. Roskienkeruulle jää vähemmän töitä. :-)
---
wcheck-mode.el | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/wcheck-mode.el b/wcheck-mode.el
index 240c6be..cca70a9 100644
--- a/wcheck-mode.el
+++ b/wcheck-mode.el
@@ -1087,16 +1087,16 @@ according to A's and all overlapping A B ranges are
combined."
(let ((alist (sort (copy-tree alist)
#'(lambda (a b)
(< (car a) (car b)))))
- ready prev)
+ final previous)
(while alist
- (while (not (equal prev alist))
- (setq prev alist
- alist (append (wcheck-combine-two (car prev) (cadr prev))
- (nthcdr 2 prev))))
- (setq ready (append ready (list (car alist)))
+ (while (not (equal previous alist))
+ (setq previous alist
+ alist (append (wcheck-combine-two (car previous) (cadr previous))
+ (nthcdr 2 previous))))
+ (setq final (cons (car alist) final)
alist (cdr alist)
- prev nil))
- ready))
+ previous nil))
+ (nreverse final)))
(defun wcheck-combine-two (a b)
@@ -1105,7 +1105,7 @@ according to A's and all overlapping A B ranges are
combined."
(b1 (car b))
(b2 (cdr b)))
(cond ((and a b)
- (if (>= a2 b1)
+ (if (>= (1+ a2) b1)
(list (cons a1 (if (> b2 a2) b2 a2)))
(list a b)))
((not a) (list b))