scm_mkstrport: Optimize the POS -> BYTE_POS conversion.
authorMark H Weaver <mhw@netris.org>
Tue, 18 Jun 2019 06:09:16 +0000 (02:09 -0400)
committerMark H Weaver <mhw@netris.org>
Tue, 18 Jun 2019 07:04:41 +0000 (03:04 -0400)
* libguile/strports.c (scm_mkstrport): Use 'scm_c_string_utf8_length' to
avoid the conversion to UTF-8.

libguile/strports.c

index 876a62a8640572d31bed5886002127d614f68ada..14cdfa06b48f0a085e3918c61f13686984187cee 100644 (file)
@@ -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);