Micro-optimization to delimiter?
authorAndy Wingo <wingo@pobox.com>
Wed, 17 Feb 2021 11:04:18 +0000 (12:04 +0100)
committerAndy Wingo <wingo@pobox.com>
Wed, 17 Feb 2021 11:04:18 +0000 (12:04 +0100)
* module/ice-9/read.scm (read): Make sure we hit the "case"
  optimization.

module/ice-9/read.scm

index 98261e2b56d7a82fd57b7edba6aac6dec5f7b24a..a14ad0259d3a880a67c2e645473405a0c0c447b2 100644 (file)
     (take-until first (lambda (ch) (not (pred ch)))))
 
   (define (delimiter? ch)
-    (or (memv ch '(#\( #\) #\; #\"
-                   #\space #\return #\ff #\newline #\tab))
-        (and (memv ch '(#\[ #\])) (or (square-brackets?) (curly-infix?)))
-        (and (memv ch '(#\{ #\})) (curly-infix?))))
+    (case ch
+      ((#\( #\) #\; #\" #\space #\return #\ff #\newline #\tab) #t)
+      ((#\[ #\]) (or (square-brackets?) (curly-infix?)))
+      ((#\{ #\}) (curly-infix?))
+      (else #f)))
 
   (define (read-token ch)
     (take-until ch delimiter?))