Avoid regexp-replace* unless the string really contains escapable characters.

This commit is contained in:
Danny Yoo 2012-11-07 16:03:04 -07:00
parent 40116eb16d
commit 5cb2f3eb58
2 changed files with 10 additions and 2 deletions

View File

@ -168,7 +168,15 @@
(define (escape x table)
(regexp-replace* table x replace-escaped))
(define (display/escape x table out)
(cond [(regexp-match table x)
(display (escape x table) out)]
[else
(display x out)]))
(provide escape
display/escape
escape-table
escape-attribute-table
lowercase-symbol

View File

@ -141,7 +141,7 @@
(display (car att) out)
(display "=" out)
(display "\"" out)
(display (escape (cadr att) escape-attribute-table) out)
(display/escape (cadr att) escape-attribute-table out)
(display "\"" out))
; Write end of opening tag
(if (and (null? content)
@ -161,7 +161,7 @@
(display ">" out)))]
; PCData
[(string? x)
(display (escape x escape-table) out)]
(display/escape x escape-table out)]
; Entities
[(symbol? x)
(display "&" out)