From 06a7d91738042e9e1a33f3ec34f37c00af24b031 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Subject: [PATCH 11/39] fix declarations and logic in {INC,DEC}-WORD-COUNT --- src/lisp/structs.lisp | 18 ++++++++---------- 1 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/lisp/structs.lisp b/src/lisp/structs.lisp index c79cd69..e75592a 100755 --- a/src/lisp/structs.lisp +++ b/src/lisp/structs.lisp @@ -206,21 +206,19 @@ (defun inc-word-count (tr) (declare (type trie tr)) - (declare (type trie parent)) (let ((parent (trie-parent tr))) - (if (not (eql nil parent)) - (progn - (setf (trie-word-count parent) (+ (trie-word-count parent) 1)) - (inc-word-count parent))))) + (declare (type (or null trie) parent)) + (when parent + (setf (trie-word-count parent) (+ (trie-word-count parent) 1)) + (inc-word-count parent)))) (defun dec-word-count(tr) (declare (type trie tr)) - (declare (type trie parent)) (let ((parent (trie-parent tr))) - (if (not (eql nil parent)) - (progn - (setf (trie-word-count parent) (- (trie-word-count parent) 1)) - (dec-word-count parent))))) + (declare (type (or null trie) parent)) + (when parent + (setf (trie-word-count parent) (- (trie-word-count parent) 1)) + (dec-word-count parent)))) (defun get-child (tr ch) (declare (type trie tr) -- 1.6.2