forked from cadence/breezewiki
use faster string split
This commit is contained in:
parent
8274e6cf1f
commit
3f1946a3b8
1 changed files with 3 additions and 1 deletions
|
@ -190,7 +190,9 @@
|
||||||
'(body "Hey" (& nbsp) (a (@ (href "/"))))))
|
'(body "Hey" (& nbsp) (a (@ (href "/"))))))
|
||||||
|
|
||||||
(define (has-class? name attributes)
|
(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
|
(module+ test
|
||||||
(check-true (has-class? "red" '((class "yellow red blue"))))
|
(check-true (has-class? "red" '((class "yellow red blue"))))
|
||||||
(check-false (has-class? "red" '((class "yellow blue"))))
|
(check-false (has-class? "red" '((class "yellow blue"))))
|
||||||
|
|
Loading…
Reference in a new issue