mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
Optimize empty substring case of scm_i_substring_copy
* libguile/strings.c (scm_i_substring_copy): When asked to create an empty substring, use 'scm_i_make_string' to make use of its optimization for empty strings that reuses the global null_stringbuf.
This commit is contained in:
parent
d6cb0203cb
commit
d5b75b6c80
1 changed files with 27 additions and 22 deletions
|
@ -372,6 +372,10 @@ scm_i_substring_read_only (SCM str, size_t start, size_t end)
|
|||
SCM
|
||||
scm_i_substring_copy (SCM str, size_t start, size_t end)
|
||||
{
|
||||
if (start == end)
|
||||
return scm_i_make_string (0, NULL, 0);
|
||||
else
|
||||
{
|
||||
size_t len = end - start;
|
||||
SCM buf, my_buf, substr;
|
||||
size_t str_start;
|
||||
|
@ -397,6 +401,7 @@ scm_i_substring_copy (SCM str, size_t start, size_t end)
|
|||
if (wide)
|
||||
scm_i_try_narrow_string (substr);
|
||||
return substr;
|
||||
}
|
||||
}
|
||||
|
||||
SCM
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue