mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 19:50:24 +02:00
Avoid calling `u32_conv_from_encoding' on the null string
* libguile/strings.c (scm_from_stringn): Avoid calling `u32_conv_from_encoding' on the null string, by using the same fast-path code used if (encoding == NULL). This is an optimization, and also avoids any possible encoding errors.
This commit is contained in:
parent
3248c954db
commit
7532125912
1 changed files with 2 additions and 2 deletions
|
@ -1473,9 +1473,9 @@ scm_from_stringn (const char *str, size_t len, const char *encoding,
|
||||||
if (len == (size_t) -1)
|
if (len == (size_t) -1)
|
||||||
len = strlen (str);
|
len = strlen (str);
|
||||||
|
|
||||||
if (encoding == NULL)
|
if (encoding == NULL || len == 0)
|
||||||
{
|
{
|
||||||
/* If encoding is null, use Latin-1. */
|
/* If encoding is null (or the string is empty), use Latin-1. */
|
||||||
char *buf;
|
char *buf;
|
||||||
res = scm_i_make_string (len, &buf, 0);
|
res = scm_i_make_string (len, &buf, 0);
|
||||||
memcpy (buf, str, len);
|
memcpy (buf, str, len);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue