Avoid UTF-8/ASCII transcoding if possible (and perform the transcoding if necessary).
authorJoe Marshall <eval.apply@gmail.com>
Wed, 18 Jan 2012 04:25:44 +0000 (20:25 -0800)
committerJoe Marshall <eval.apply@gmail.com>
Wed, 18 Jan 2012 04:25:44 +0000 (20:25 -0800)
src/runtime/symbol.scm

index b8886e7f3b27134f67c196a4e0a81dfa1accd6e3..c1e5a69796a2f458ea0bdab91ee59fbedd0b4493 100644 (file)
@@ -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