From 566c6a6a8e0119ed6f3cfc927f000950d1987bec Mon Sep 17 00:00:00 2001 Message-Id: <566c6a6a8e0119ed6f3cfc927f000950d1987bec.1715368971.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sun, 26 Mar 2017 15:16:18 +0100 Subject: [PATCH] src/class-finalize-impl.lisp (clos-tiebreaker): Refactor. Organization: Straylight/Edgeware From: Mark Wooding An early exit is cleaner than assignment and a nil check. --- src/class-finalize-impl.lisp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/class-finalize-impl.lisp b/src/class-finalize-impl.lisp index ce3282f..6be6b49 100644 --- a/src/class-finalize-impl.lisp +++ b/src/class-finalize-impl.lisp @@ -72,14 +72,11 @@ (defun clos-tiebreaker (candidates so-far) direct subclass then that subclass's direct superclasses list must order them relative to each other." - (let (winner) - (dolist (class so-far) - (dolist (candidate candidates) - (when (member candidate (sod-class-direct-superclasses class)) - (setf winner candidate)))) - (unless winner - (error "SOD INTERNAL ERROR: Failed to break tie in CLOS")) - winner)) + (dolist (class so-far) + (dolist (candidate candidates) + (when (member candidate (sod-class-direct-superclasses class)) + (return-from clos-tiebreaker candidate)))) + (error "SOD INTERNAL ERROR: Failed to break tie in CLOS")) (defun c3-tiebreaker (candidates cpls) "The C3 linearization tiebreaker function. -- [mdw]