diff options
author | Mark H Weaver <mhw@netris.org> | 2012-01-10 06:18:31 -0500 |
---|---|---|
committer | Mark H Weaver <mhw@netris.org> | 2012-01-10 06:33:17 -0500 |
commit | 7532125912a381c0770aa7af596b7401942c685b (patch) | |
tree | 897166ebe135276506d28628c4c137570afb5052 /libguile/strings.c | |
parent | 3248c954dbd67a2abb67ffbc470feaeb8c8dd0d3 (diff) | |
download | guile-7532125912a381c0770aa7af596b7401942c685b.tar.gz |
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.
Diffstat (limited to 'libguile/strings.c')
-rw-r--r-- | libguile/strings.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libguile/strings.c b/libguile/strings.c index 73c0a5ce0..c94a2000a 100644 --- a/libguile/strings.c +++ b/libguile/strings.c @@ -1473,9 +1473,9 @@ scm_from_stringn (const char *str, size_t len, const char *encoding, if (len == (size_t) -1) 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; res = scm_i_make_string (len, &buf, 0); memcpy (buf, str, len); |