ttn pushed a commit to branch master in repository elpa. commit 4b9f836c3cd8b0546ea725fbafbf395847f588f4 Author: Thien-Thi Nguyen <t...@gnu.org> Date: Mon Mar 24 12:09:16 2014 +0100
[gnugo int] Embrace (NODE[...] [SUBTREE...]) IR, for now. It's not so bad, after all. OTOH, hanging by the leaves is better. * packages/gnugo/gnugo.el (gnugo/sgf-read-file TREE): Use ‘nconc’. (gnugo/sgf-write-file >>tree): Use ‘dolist’. --- packages/gnugo/gnugo.el | 27 +++++++-------------------- 1 files changed, 7 insertions(+), 20 deletions(-) diff --git a/packages/gnugo/gnugo.el b/packages/gnugo/gnugo.el index 5a0ef59..d434cab 100644 --- a/packages/gnugo/gnugo.el +++ b/packages/gnugo/gnugo.el @@ -2184,11 +2184,8 @@ starting a new one. See `gnugo-board-mode' documentation for more info." (setq SZ (cdr prop))) prop)))) (TREE (lev) (prog1 - ;; hmm - ;; ‘append’ => ([NODE...] [SUBTREE...]) - ;; ‘cons’ => (([NODE...]) . [SUBTREE...]) - ;; see consequent hair in -write-file - (append + ;; produce (NODE[...] [SUBTREE...]) + (nconc ;; nodes (loop while (seek ?\;) collect (NODE)) @@ -2253,21 +2250,11 @@ starting a new one. See `gnugo-board-mode' documentation for more info." (unless (zerop (current-column)) (newline)) (insert "(") - ;; The IR (see "hmm" above) prioritizes space - ;; efficiency; no cost if no subtrees (common case). - ;; The downside, however, is that subtree access - ;; requires this somewhat-funky border search. - (let (x subtrees) - (while (setq x (pop tree)) - (if (gnugo--nodep x) - (>>node x) - (setq - ;; Add back the first subtree. - subtrees (cons x tree) - ;; Arrange to stop searching. - tree nil))) - (dolist (sub subtrees) - (>>tree sub))) + (dolist (x tree) + (funcall (if (gnugo--nodep x) + #'>>node + #'>>tree) + x)) (insert ")"))) (with-temp-buffer (dolist (tree collection)