From 9f7a824206702350427aa59382082d1019c3011d Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Tue, 18 Jun 2019 02:09:16 -0400 Subject: [PATCH] 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. --- libguile/strports.c | 4 ++-- 1 file 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);