use faster string split

This commit is contained in:
Artemis Everfree 2023-03-22 21:44:40 -07:00
parent d1c348a853
commit 2694eb7245
1 changed files with 3 additions and 1 deletions

View File

@ -190,7 +190,9 @@
'(body "Hey" (& nbsp) (a (@ (href "/"))))))
(define (has-class? name attributes)
(and (member name (string-split (or (get-attribute 'class attributes) "") " ")) #t))
; splitting without specifying separator or splitting on #px"\\s+" makes
; string-split use a faster whitespace-specialized implementation.
(and (member name (string-split (or (get-attribute 'class attributes) "") #px"\\s+")) #t))
(module+ test
(check-true (has-class? "red" '((class "yellow red blue"))))
(check-false (has-class? "red" '((class "yellow blue"))))