From a33ebecfe305f02921a300768b455dc7280b37c4 Mon Sep 17 00:00:00 2001 From: Joe Marshall Date: Tue, 17 Jan 2012 20:25:44 -0800 Subject: [PATCH] Avoid UTF-8/ASCII transcoding if possible (and perform the transcoding if necessary). --- src/runtime/symbol.scm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/runtime/symbol.scm b/src/runtime/symbol.scm index b8886e7f3..c1e5a6979 100644 --- a/src/runtime/symbol.scm +++ b/src/runtime/symbol.scm @@ -46,7 +46,8 @@ USA. (define (string->uninterned-symbol string) (make-uninterned-symbol (if (string? string) - (string->utf8-string string) + (or (ascii-string-copy string) + (string->utf8-string string)) (wide-string->utf8-string string)))) (define (utf8-string->uninterned-symbol string) @@ -61,7 +62,8 @@ USA. (define (string->symbol string) ((ucode-primitive string->symbol) (if (string? string) - (string->utf8-string string) + (or (ascii-string-copy string) + (string->utf8-string string)) (wide-string->utf8-string string)))) (define (utf8-string->symbol string) @@ -161,4 +163,6 @@ USA. (utf8-string->wide-string (symbol-name symbol))) (define (symbol->string symbol) - (utf8-string->string (symbol-name symbol))) \ No newline at end of file + ;; `Gensyms' are constructed with this, so try the fast copy first. + (or (ascii-string-copy (symbol-name symbol)) + (utf8-string->string (symbol-name symbol)))) \ No newline at end of file -- 2.25.1