More read micro-optimizations
authorAndy Wingo <wingo@pobox.com>
Wed, 17 Feb 2021 11:10:57 +0000 (12:10 +0100)
committerAndy Wingo <wingo@pobox.com>
Wed, 17 Feb 2021 11:10:57 +0000 (12:10 +0100)
* module/ice-9/read.scm (read): Use R5RS read-char, peek-char,
  write-char rather than (ice-9 textual-ports) wrappers, because the
  latter are expressed in terms of the former.

module/ice-9/read.scm

index a14ad0259d3a880a67c2e645473405a0c0c447b2..04e3cac93f1a8424c365f2c8ebee0e8387a7a3be 100644 (file)
   (define (curly-infix?) (enabled? bitfield:curly-infix?))
   (define (r7rs-symbols?) (enabled? bitfield:r7rs-symbols?))
   (define neoteric 0)
-  (define (next) (get-char port))
-  (define (peek) (lookahead-char port))
+  (define (next) (read-char port))
+  (define (peek) (peek-char port))
   (define filename (port-filename port))
   (define (get-pos) (cons (port-line port) (port-column port)))
   (define accumulator (open-output-string))
   (define-syntax-rule (accumulate proc)
     (begin
-      (proc (lambda (ch) (put-char accumulator ch)))
+      (proc (lambda (ch) (write-char ch accumulator)))
       (let ((str (get-output-string accumulator)))
         (seek accumulator 0 SEEK_SET)
         (truncate-file accumulator 0)