summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2019-06-18 02:09:16 -0400
committerMark H Weaver <mhw@netris.org>2019-06-18 03:04:41 -0400
commit9f7a824206702350427aa59382082d1019c3011d (patch)
treeb422986fe9937234930ccb1e01e4ed2937019f1b
parent8150823fc87b837a4db3d7690a920dc2484aa1d7 (diff)
scm_mkstrport: Optimize the POS -> BYTE_POS conversion.
* libguile/strports.c (scm_mkstrport): Use 'scm_c_string_utf8_length' to avoid the conversion to UTF-8.
-rw-r--r--libguile/strports.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libguile/strports.c b/libguile/strports.c
index 876a62a86..14cdfa06b 100644
--- a/libguile/strports.c
+++ b/libguile/strports.c
@@ -195,8 +195,8 @@ scm_mkstrport (SCM pos, SCM str, long modes, const char *caller)
else
/* Inefficient but simple way to convert the character position
POS into a byte position BYTE_POS. */
- free (scm_to_utf8_stringn (scm_substring (str, SCM_INUM0, pos),
- &byte_pos));
+ byte_pos = scm_c_string_utf8_length
+ (scm_substring (str, SCM_INUM0, pos));
}
stream = scm_gc_typed_calloc (struct string_port);