From 959372a773c2ec6b66559f6f3bc884c910faceec Mon Sep 17 00:00:00 2001 From: Nathan Froyd Subject: [PATCH 20/39] remove some ccl/null pointer bogosity --- src/lisp/solver.lisp | 27 ++++++++++++--------------- 1 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/lisp/solver.lisp b/src/lisp/solver.lisp index 7673a69..8f63727 100755 --- a/src/lisp/solver.lisp +++ b/src/lisp/solver.lisp @@ -63,9 +63,7 @@ (declare (type string word) - #+sbcl (type (or trie (unsigned-byte 8)) tr) - ;; ccl is smart enough to not barf on a 0 pointer - #+ccl (type trie tr) + (type trie tr) (type letter ltr) (type (unsigned-byte 8) fi)) @@ -96,18 +94,17 @@ ;; yield to the passed in func (funcall word-func word)) - (setf tr (aref (trie-children tr) - (- (char-code cc) (char-code #\A)))) - - ;; try longer words with neighbors - (if (and (not (eql tr 0)) - (<= fi *max-search-depth*)) - (let ((neighbors (letter-neighbors ltr))) - (dotimes (i (length neighbors)) - (let ((neighbor (aref neighbors i))) - #+ccl (declare (type letter neighbor)) - (if (not (letter-used neighbor)) - (find-words neighbor word fi tr word-func)))))) + (let ((child (aref (trie-children tr) + (- (char-code cc) (char-code #\A))))) + ;; try longer words with neighbors + (if (and (not (eql child 0)) + (<= fi (trie-level child))) + (let ((neighbors (letter-neighbors ltr))) + (dotimes (i (length neighbors)) + (let ((neighbor (aref neighbors i))) + #+ccl (declare (type letter neighbor)) + (if (not (letter-used neighbor)) + (find-words neighbor word fi child word-func))))))) ;; the letter is no longer in use (setf (letter-used ltr) nil))) -- 1.6.2