From d1d775a8024f82aaeaf98e86afeabff1b4806f03 Mon Sep 17 00:00:00 2001
From: toy <toy>
Date: Fri, 9 Jan 2004 04:18:06 +0000
Subject: [PATCH] Revert back to the old LCM algorithm instead of using the
 reference given in CLHS.  That was twice as slow as the old algorithm.

---
 code/numbers.lisp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/code/numbers.lisp b/code/numbers.lisp
index d03d17416..750274a35 100644
--- a/code/numbers.lisp
+++ b/code/numbers.lisp
@@ -5,7 +5,7 @@
 ;;; Carnegie Mellon University, and has been placed in the public domain.
 ;;;
 (ext:file-comment
-  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/numbers.lisp,v 1.55 2003/09/09 12:33:39 gerd Exp $")
+  "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/numbers.lisp,v 1.56 2004/01/09 04:18:06 toy Exp $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -1351,7 +1351,13 @@ significant bit of INTEGER is bit 0."
   (declare (integer n m))
   (if (or (zerop n) (zerop m))
       0
-      (/ (abs (* n m)) (gcd n m))))
+      (let ((m (abs m))
+	    (n (abs n)))
+	(multiple-value-bind (max min)
+	    (if (> m n)
+		(values m n)
+		(values n m))
+	  (* (truncate max (gcd n m)) min)))))
 
 
 ;;; TWO-ARG-GCD  --  Internal
-- 
GitLab