From: Joe Marshall Date: Wed, 18 Jan 2012 04:25:44 +0000 (-0800) Subject: Avoid UTF-8/ASCII transcoding if possible (and perform the transcoding if necessary). X-Git-Tag: release-9.2.0~334^2~13 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=a33ebecfe305f02921a300768b455dc7280b37c4;p=mit-scheme.git Avoid UTF-8/ASCII transcoding if possible (and perform the transcoding if necessary). --- 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