[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/gnugo 7114ed6 234/357: [gnugo int] Add abstraction: gnu

From: Stefan Monnier
Subject: [elpa] externals/gnugo 7114ed6 234/357: [gnugo int] Add abstraction: gnugo--mem-with-played-stone
Date: Sun, 29 Nov 2020 14:51:29 -0500 (EST)

branch: externals/gnugo
commit 7114ed66c838abb603436f062c258375c415f66c
Author: Thien-Thi Nguyen <ttn@gnu.org>
Commit: Thien-Thi Nguyen <ttn@gnu.org>

    [gnugo int] Add abstraction: gnugo--mem-with-played-stone
    * packages/gnugo/gnugo.el (gnugo--mem-with-played-stone): New func.
    (gnugo--node-with-played-stone): Use it; convert to defsubst.
 gnugo.el | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/gnugo.el b/gnugo.el
index 10e29e2..52aeb84 100644
--- a/gnugo.el
+++ b/gnugo.el
@@ -1929,6 +1929,17 @@ If FILENAME already exists, Emacs confirms that you wish 
to overwrite it."
     (set-buffer-modified-p nil)
     (gnugo--who-is-who wait play samep)))
+(defun gnugo--mem-with-played-stone (pos)
+  (let ((color (case (following-char)
+                 (?X :B)
+                 (?O :W))))
+    (when color
+      (loop with fruit = (cons color (funcall (gnugo--as-cc-func) pos))
+            for mem on (aref (gnugo-get :monkey) 0)
+            when (equal fruit (caar mem))
+            return mem
+            finally return nil))))
 (defun gnugo-magic-undo (spec &optional noalt keep)
   "Undo moves on the GNUGO Board, based on SPEC, a string or number.
 If SPEC is a string in the form of a board position (e.g., \"T19\"),
@@ -2244,16 +2255,8 @@ which placed the stone at point."
   (save-excursion (gnugo-refresh)))
-(defun gnugo--node-with-played-stone (pos)
-  (let ((color (case (following-char)
-                 (?X :B)
-                 (?O :W))))
-    (when color
-      (loop with fruit = (cons color (funcall (gnugo--as-cc-func) pos))
-            for node in (aref (gnugo-get :monkey) 0)
-            if (equal fruit (car node))
-            return node
-            finally return nil))))
+(defsubst gnugo--node-with-played-stone (pos)
+  (car (gnugo--mem-with-played-stone pos)))
 (defun gnugo-describe-position ()
   "Display the board position under cursor in the echo area.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]