Replace non-greedy regexp with a char-complement to improve matching performance.

Measurements show a runtime improvement of about 10% for string-heavy
JSON documents.  http://lists.racket-lang.org/users/archive/2013-January/055953.html
This commit is contained in:
Danny Yoo 2013-01-15 15:34:36 -07:00
parent 8562310f38
commit aa3f44dffa

View File

@ -107,7 +107,7 @@
(define (read-string)
(let loop ([l* '()])
;; note: use a string regexp to extract utf-8-able text
(define m (cdr (or (regexp-try-match #rx"^(.*?)(\"|\\\\(.))" i)
(define m (cdr (or (regexp-try-match #rx"^([^\"\\]*)(\"|\\\\(.))" i)
(err "unterminated string"))))
(define l (if ((bytes-length (car m)) . > . 0) (cons (car m) l*) l*))
(define esc (caddr m))