~ chicken-core (master) abe695510aeb59be18af7203caaf9471abab1db4
commit abe695510aeb59be18af7203caaf9471abab1db4
Author: felix <felix@call-with-current-continuation.org>
AuthorDate: Mon Sep 7 23:03:45 2026 +0200
Commit: Felix Winkelmann <felix.winkelmann@bevuta.com>
CommitDate: Wed Sep 9 13:45:43 2026 +0200
avoid slowing down fast path
diff --git a/library.scm b/library.scm
index 09caa72b..f79eb0b6 100644
--- a/library.scm
+++ b/library.scm
@@ -2515,19 +2515,19 @@ EOF
(let ((g (%integer-gcd x y)))
(ratnum (%integer-quotient x g) (%integer-quotient y g))))
;; Compnum *must* be checked first
- ((and (cplxnum? x) (not (cplxnum? y)))
- (let* ((a (real-part x)) (b (imag-part x))
- (xu (##sys#/-2 a y))
- (yu (##sys#/-2 b y)))
- (make-complex xu yu)))
((or (cplxnum? x) (cplxnum? y))
- (let* ((a (real-part x)) (b (imag-part x))
- (c (real-part y)) (d (imag-part y))
- (r (+ (* c c) (* d d)))
- (x (##sys#/-2 (+ (* a c) (* b d)) r))
- (y (##sys#/-2 (- (* b c) (* a d)) r)) )
- (make-complex x y) ))
- ((or (##core#inline "C_i_flonump" x) (##core#inline "C_i_flonump" y))
+ (if (cplxnum? y)
+ (let* ((a (real-part x)) (b (imag-part x))
+ (c (real-part y)) (d (imag-part y))
+ (r (+ (* c c) (* d d)))
+ (x (##sys#/-2 (+ (* a c) (* b d)) r))
+ (y (##sys#/-2 (- (* b c) (* a d)) r)) )
+ (make-complex x y) )
+ (let* ((a (real-part x)) (b (imag-part x))
+ (xu (##sys#/-2 a y))
+ (yu (##sys#/-2 b y)))
+ (make-complex xu yu))))
+ ((or (##core#inline "C_i_flonump" x) (##core#inline "C_i_flonump" y))
;; This may be incorrect when one is a ratnum consisting of bignums
(fp/ (exact->inexact x) (exact->inexact y)))
((ratnum? x)
Trap