guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] 02/03: Remove unnecessary scm_i_string_start_writing cal


From: Andy Wingo
Subject: [Guile-commits] 02/03: Remove unnecessary scm_i_string_start_writing calls
Date: Thu, 16 Feb 2017 08:34:31 -0500 (EST)

wingo pushed a commit to branch master
in repository guile.

commit c38b9625c88f4d1760068926273b6d89ffbd4527
Author: Andy Wingo <address@hidden>
Date:   Thu Feb 16 10:43:23 2017 +0100

    Remove unnecessary scm_i_string_start_writing calls
    
    * libguile/strings.c (scm_string, scm_c_make_string):
    * libguile/srfi-13.c (scm_reverse_list_to_string, scm_string_map)
      (scm_string_unfold, scm_string_unfold_right, scm_xsubstring)
      (scm_string_filter, scm_string_delete): Remove
      scm_i_string_start_writing / scm_i_string_stop_writing calls around
      fresh strings that aren't visible to other threads.
---
 libguile/read.c    |  6 ++----
 libguile/srfi-13.c | 30 ++++++++++++++----------------
 libguile/strings.c |  5 -----
 3 files changed, 16 insertions(+), 25 deletions(-)

diff --git a/libguile/read.c b/libguile/read.c
index 085cdb9..0946ff3 100644
--- a/libguile/read.c
+++ b/libguile/read.c
@@ -1556,7 +1556,8 @@ scm_read_extended_symbol (scm_t_wchar chr, SCM port)
   size_t len = 0;
   SCM buf = scm_i_make_string (1024, NULL, 0);
 
-  buf = scm_i_string_start_writing (buf);
+  /* No need to scm_i_string_start_writing (), as the string isn't
+     visible to any other thread.  */
 
   while ((chr = scm_getc (port)) != EOF)
     {
@@ -1620,16 +1621,13 @@ scm_read_extended_symbol (scm_t_wchar chr, SCM port)
        {
          SCM addy;
 
-         scm_i_string_stop_writing ();
          addy = scm_i_make_string (1024, NULL, 0);
          buf = scm_string_append (scm_list_2 (buf, addy));
          len = 0;
-         buf = scm_i_string_start_writing (buf);
        }
     }
 
  done:
-  scm_i_string_stop_writing ();
   if (chr == EOF)
     scm_i_input_error ("scm_read_extended_symbol", port,
                        "end of file while reading symbol", SCM_EOL);
diff --git a/libguile/srfi-13.c b/libguile/srfi-13.c
index 5c30dfe..c77cba9 100644
--- a/libguile/srfi-13.c
+++ b/libguile/srfi-13.c
@@ -351,7 +351,8 @@ SCM_DEFINE (scm_reverse_list_to_string, 
"reverse-list->string", 1, 0, 0,
       }
     rest = chrs;
     j = i;
-    result = scm_i_string_start_writing (result);
+    /* No need to scm_i_string_start_writing (), as the string isn't
+       visible to any other thread.  */
     while (j > 0 && scm_is_pair (rest))
       {
         SCM elt = SCM_CAR (rest);
@@ -359,7 +360,6 @@ SCM_DEFINE (scm_reverse_list_to_string, 
"reverse-list->string", 1, 0, 0,
         rest = SCM_CDR (rest);
         j--;
       }
-    scm_i_string_stop_writing ();
   }
 
   return result;
@@ -2515,9 +2515,9 @@ SCM_DEFINE (scm_string_map, "string-map", 2, 2, 0,
       if (!SCM_CHARP (ch))
        SCM_MISC_ERROR ("procedure ~S returned non-char", scm_list_1 (proc));
       cstart++;
-      result = scm_i_string_start_writing (result);
+      /* No need to scm_i_string_start_writing (), as the string isn't
+         visible to any other thread.  */
       scm_i_string_set_x (result, p, SCM_CHAR (ch));
-      scm_i_string_stop_writing ();
       p++;
     }
   
@@ -2658,9 +2658,9 @@ SCM_DEFINE (scm_string_unfold, "string-unfold", 4, 2, 0,
       if (!SCM_CHARP (ch))
        SCM_MISC_ERROR ("procedure ~S returned non-char", scm_list_1 (f));
       str = scm_i_make_string (1, NULL, 0);
-      str = scm_i_string_start_writing (str);
+      /* No need to scm_i_string_start_writing (), as the string isn't
+         visible to any other thread.  */
       scm_i_string_set_x (str, i, SCM_CHAR (ch));
-      scm_i_string_stop_writing ();
       i++;
 
       ans = scm_string_append (scm_list_2 (ans, str));
@@ -2724,9 +2724,9 @@ SCM_DEFINE (scm_string_unfold_right, 
"string-unfold-right", 4, 2, 0,
       if (!SCM_CHARP (ch))
        SCM_MISC_ERROR ("procedure ~S returned non-char", scm_list_1 (f));
       str = scm_i_make_string (1, NULL, 0);
-      str = scm_i_string_start_writing (str);
+      /* No need to scm_i_string_start_writing (), as the string isn't
+         visible to any other thread.  */
       scm_i_string_set_x (str, i, SCM_CHAR (ch));
-      scm_i_string_stop_writing ();
       i++;
 
       ans = scm_string_append (scm_list_2 (str, ans));
@@ -2839,7 +2839,6 @@ SCM_DEFINE (scm_xsubstring, "xsubstring", 2, 3, 0,
     SCM_MISC_ERROR ("start and end indices must not be equal", SCM_EOL);
 
   result = scm_i_make_string (cto - cfrom, NULL, 0);
-  result = scm_i_string_start_writing (result);
 
   p = 0;
   while (cfrom < cto)
@@ -2853,7 +2852,6 @@ SCM_DEFINE (scm_xsubstring, "xsubstring", 2, 3, 0,
       cfrom++;
       p++;
     }
-  scm_i_string_stop_writing ();
 
   scm_remember_upto_here_1 (s);
   return result;
@@ -3191,8 +3189,9 @@ SCM_DEFINE (scm_string_filter, "string-filter", 2, 2, 0,
         {
           size_t dst = 0;
           result = scm_i_make_string (count, NULL, 0);
-         result = scm_i_string_start_writing (result);
 
+          /* No need to scm_i_string_start_writing (), as the string isn't
+             visible to any other thread.  */
           /* decrement "count" in this loop as well as using idx, so that if
              another thread is simultaneously changing "s" there's no chance
              it'll make us copy more than count characters */
@@ -3205,7 +3204,6 @@ SCM_DEFINE (scm_string_filter, "string-filter", 2, 2, 0,
                   count--;
                 }
             }
-         scm_i_string_stop_writing ();
         }
     }
   else
@@ -3301,7 +3299,8 @@ SCM_DEFINE (scm_string_delete, "string-delete", 2, 2, 0,
          int i = 0;
           /* new string for retained portion */
           result = scm_i_make_string (count, NULL, 0); 
-          result = scm_i_string_start_writing (result);
+          /* No need to scm_i_string_start_writing (), as the string isn't
+             visible to any other thread.  */
           /* decrement "count" in this loop as well as using idx, so that if
              another thread is simultaneously changing "s" there's no chance
              it'll make us copy more than count characters */
@@ -3315,7 +3314,6 @@ SCM_DEFINE (scm_string_delete, "string-delete", 2, 2, 0,
                   count--;
                 }
             }
-         scm_i_string_stop_writing ();
         }
     }
   else if (SCM_CHARSETP (char_pred))
@@ -3343,8 +3341,9 @@ SCM_DEFINE (scm_string_delete, "string-delete", 2, 2, 0,
          size_t i = 0;
           /* new string for retained portion */
           result = scm_i_make_string (count, NULL, 0);
-         result = scm_i_string_start_writing (result);
 
+          /* No need to scm_i_string_start_writing (), as the string isn't
+             visible to any other thread.  */
           /* decrement "count" in this loop as well as using idx, so that if
              another thread is simultaneously changing "s" there's no chance
              it'll make us copy more than count characters */
@@ -3357,7 +3356,6 @@ SCM_DEFINE (scm_string_delete, "string-delete", 2, 2, 0,
                   count--;
                 }
             }
-         scm_i_string_stop_writing ();
         }
     }
   else
diff --git a/libguile/strings.c b/libguile/strings.c
index cdbc358..a153d29 100644
--- a/libguile/strings.c
+++ b/libguile/strings.c
@@ -1145,7 +1145,6 @@ SCM_DEFINE (scm_string, "string", 0, 0, 1,
       char *buf;
 
       result = scm_i_make_string (len, NULL, 0);
-      result = scm_i_string_start_writing (result);
       buf = scm_i_string_writable_chars (result);
       while (len > 0 && scm_is_pair (rest))
         {
@@ -1162,7 +1161,6 @@ SCM_DEFINE (scm_string, "string", 0, 0, 1,
       scm_t_wchar *buf;
 
       result = scm_i_make_wide_string (len, NULL, 0);
-      result = scm_i_string_start_writing (result);
       buf = scm_i_string_writable_wide_chars (result);
       while (len > 0 && scm_is_pair (rest))
         {
@@ -1174,7 +1172,6 @@ SCM_DEFINE (scm_string, "string", 0, 0, 1,
           scm_remember_upto_here_1 (elt);
         }
     }
-  scm_i_string_stop_writing ();
 
   if (len > 0)
     scm_misc_error (NULL, "list changed while constructing string", SCM_EOL);
@@ -1211,10 +1208,8 @@ scm_c_make_string (size_t len, SCM chr)
   else
     {
       SCM_VALIDATE_CHAR (0, chr);
-      res = scm_i_string_start_writing (res);
       for (p = 0; p < len; p++)
         scm_i_string_set_x (res, p, SCM_CHAR (chr));
-      scm_i_string_stop_writing ();
     }
 
   return res;



reply via email to

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