From ecafa799d37688e4bf74d350a27ca04711d5ef96 Mon Sep 17 00:00:00 2001 From: Thomas Hintz Date: Sat, 18 Oct 2014 09:55:48 -0700 Subject: [PATCH] Improving performance of first case in UTF8 validation grammar. --- utf8-grammar.scm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/utf8-grammar.scm b/utf8-grammar.scm index ec266ae..7d8b277 100644 --- a/utf8-grammar.scm +++ b/utf8-grammar.scm @@ -1,7 +1,3 @@ -(import chicken scheme) -(use srfi-4 srfi-13 srfi-14 comparse) - - (define (ucs-range->char-set/inclusive lower upper) (ucs-range->char-set lower (add1 upper))) @@ -9,7 +5,9 @@ (in (ucs-range->char-set/inclusive #x80 #xBF))) (define utf8-1 - (in (ucs-range->char-set/inclusive #x00 #x7F))) + (satisfies (lambda (c) (or (< (char->integer c) 128) + (and (> (char->integer c) 128) + (< (char->integer c) 191)))))) (define utf8-2 (sequence