guile-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

guile/guile-core/libguile ChangeLog numbers.c


From: Dirk Herrmann
Subject: guile/guile-core/libguile ChangeLog numbers.c
Date: Mon, 09 Oct 2000 02:54:29 -0700

CVSROOT:        /cvs
Module name:    guile
Changes by:     Dirk Herrmann <address@hidden>  00/10/09 02:54:28

Modified files:
        guile-core/libguile: ChangeLog numbers.c 

Log message:
        * Eliminate previously introduced redundant string copying.

CVSWeb URLs:
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/ChangeLog.diff?r1=1.1135&r2=1.1136
http://subversions.gnu.org/cgi-bin/cvsweb/guile/guile-core/libguile/numbers.c.diff?r1=1.104&r2=1.105

Patches:
Index: guile/guile-core/libguile/ChangeLog
diff -u guile/guile-core/libguile/ChangeLog:1.1135 
guile/guile-core/libguile/ChangeLog:1.1136
--- guile/guile-core/libguile/ChangeLog:1.1135  Fri Oct  6 09:51:07 2000
+++ guile/guile-core/libguile/ChangeLog Mon Oct  9 02:54:28 2000
@@ -1,3 +1,9 @@
+2000-10-09  Dirk Herrmann  <address@hidden>
+
+       * numbers.c (big2str):  Avoid redundant copying.
+
+       (scm_bigprint):  Use SCM_STRING_LENGTH instead of SCM_LENGTH.
+
 2000-10-06  Dirk Herrmann  <address@hidden>
 
        * numbers.c (big2str), read.c (scm_grow_tok_buf), strports.c
Index: guile/guile-core/libguile/numbers.c
diff -u guile/guile-core/libguile/numbers.c:1.104 
guile/guile-core/libguile/numbers.c:1.105
--- guile/guile-core/libguile/numbers.c:1.104   Fri Oct  6 09:51:07 2000
+++ guile/guile-core/libguile/numbers.c Mon Oct  9 02:54:28 2000
@@ -2175,7 +2175,6 @@
     : (SCM_BITSPERDIG * i) + 2;
   scm_sizet k = 0;
   scm_sizet radct = 0;
-  scm_sizet ch;                        /* jeh */
   SCM_BIGDIG radpow = 1, radmod = 0;
   SCM ss = scm_makstr ((long) j, 0);
   char *s = SCM_STRING_CHARS (ss), c;
@@ -2184,7 +2183,6 @@
       radpow *= radix;
       radct++;
     }
-  s[0] = SCM_BIGSIGN (b) ? '-' : '+';
   while ((i || radmod) && j)
     {
       if (k == 0)
@@ -2199,13 +2197,15 @@
       k--;
       s[--j] = c < 10 ? c + '0' : c + 'a' - 10;
     }
-  ch = s[0] == '-' ? 1 : 0;    /* jeh */
-  if (ch < j)
-    {                          /* jeh */
-      for (i = j; j < SCM_LENGTH (ss); j++)
-       s[ch + j - i] = s[j];   /* jeh */
-      ss = scm_substring (ss, SCM_INUM0, 
-                         SCM_MAKINUM (ch + SCM_STRING_LENGTH (ss) - i));
+
+  if (SCM_BIGSIGN (b))
+    s[--j] = '-';
+
+  if (j > 0)
+    {
+      /* The pre-reserved string length was too large. */
+      unsigned long int length = SCM_STRING_LENGTH (ss);
+      ss = scm_substring (ss, SCM_MAKINUM (j), SCM_MAKINUM (length));
     }
 
   return scm_return_first (ss, t);
@@ -2270,7 +2270,7 @@
 {
 #ifdef SCM_BIGDIG
   exp = big2str (exp, (unsigned int) 10);
-  scm_lfwrite (SCM_STRING_CHARS (exp), (scm_sizet) SCM_LENGTH (exp), port);
+  scm_lfwrite (SCM_STRING_CHARS (exp), (scm_sizet) SCM_STRING_LENGTH (exp), 
port);
 #else
   scm_ipruk ("bignum", exp, port);
 #endif



reply via email to

[Prev in Thread] Current Thread [Next in Thread]