Hi,

The attached patch contains a fix to #869
(https://bugs.call-cc.org/ticket/869).

srfi-13.scm is compiled with (declare (fixnum)), but `xsubstring' and
`string-xcopy!' use / in a cond clause as a shorter path to avoid
calling `%multispan-repcopy!', which is more "expensive".

The patch just removes that shorter path, so the fixnum declaration can
be kept.

Best wishes.
Mario
-- 
http://parenteses.org/mario
>From 63ef97fabd1e5f3a908195748935a1ed69fc46bf Mon Sep 17 00:00:00 2001
From: Mario Domenech Goulart <[email protected]>
Date: Thu, 28 Jun 2012 10:46:03 -0300
Subject: [PATCH] Avoid using / in xsubstring and string-xcopy!, since srfi-13 is compiled with (declare (fixnum))

This patch fixes #869
---
 srfi-13.scm |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/srfi-13.scm b/srfi-13.scm
index e4a0509..3dbc2ca 100644
--- a/srfi-13.scm
+++ b/srfi-13.scm
@@ -1766,10 +1766,16 @@
 	    ((= 1 slen)		; Fast path for 1-char replication.
 	     (make-string anslen (string-ref s start)))
 
+	    ;; CHICKEN compiles this file with (declare (fixnum)), so
+	    ;; flonum operations are not reliable.  Since this clause
+	    ;; just provides a shorter path to avoid calling
+	    ;; %multispan-repcopy!, we comment it out and leave the
+	    ;; fixnum declaration.
+	    ;;
 	    ;; Selected text falls entirely within one span.
-	    ((= (floor (/ from slen)) (floor (/ to slen)))
-	     (##sys#substring s (+ start (modulo from slen))
-			  (+ start (modulo to   slen))))
+	    ;; ((= (floor (/ from slen)) (floor (/ to slen)))
+	    ;;  (##sys#substring s (+ start (modulo from slen))
+	    ;; 		  (+ start (modulo to   slen))))
 
 	    ;; Selected text requires multiple spans.
 	    (else (let ((ans (make-string anslen)))
@@ -1813,11 +1819,17 @@
 	    ((= 1 slen)			; Fast path for 1-char replication.
 	     (##srfi13#string-fill! target (string-ref s start) tstart tend))
 
+	    ;; CHICKEN compiles this file with (declare (fixnum)), so
+	    ;; flonum operations are not reliable.  Since this clause
+	    ;; just provides a shorter path to avoid calling
+	    ;; %multispan-repcopy!, we comment it out and leave the
+	    ;; fixnum declaration.
+	    ;;
 	    ;; Selected text falls entirely within one span.
-	    ((= (floor (/ sfrom slen)) (floor (/ sto slen)))
-	     (%string-copy! target tstart s 
-			    (+ start (modulo sfrom slen))
-			    (+ start (modulo sto   slen))))
+	    ;; ((= (floor (/ sfrom slen)) (floor (/ sto slen)))
+	    ;;  (%string-copy! target tstart s
+	    ;; 		    (+ start (modulo sfrom slen))
+	    ;; 		    (+ start (modulo sto   slen))))
 
 	    ;; Multi-span copy.
 	    (else (%multispan-repcopy! target tstart s sfrom sto start end))))))
-- 
1.7.2.5

_______________________________________________
Chicken-hackers mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to