summaryrefslogtreecommitdiff
path: root/libguile/srfi-13.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2017-02-16 10:43:23 +0100
committerAndy Wingo <wingo@pobox.com>2017-02-16 10:43:23 +0100
commitc38b9625c88f4d1760068926273b6d89ffbd4527 (patch)
tree7b768c8b10eb8eb687daa4fd4ef323a19c01d428 /libguile/srfi-13.c
parentcd3ff33a31c51612f2247bdb15ecbe92d7da1310 (diff)
downloadguile-c38b9625c88f4d1760068926273b6d89ffbd4527.tar.gz
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.
Diffstat (limited to 'libguile/srfi-13.c')
-rw-r--r--libguile/srfi-13.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/libguile/srfi-13.c b/libguile/srfi-13.c
index 5c30dfe20..c77cba9b2 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