Much more efficient line-splitting

This commit is contained in:
Jaidyn Ann 2024-02-05 22:08:25 -06:00
parent 0a5ef01169
commit ff259fe683

View File

@ -32,14 +32,10 @@
(remove string-null? (string-split string "\r\n"))) (remove string-null? (string-split string "\r\n")))
;; Create irregx-format regex for matching an unescaped character. ;; Splits a line into a cons of the property-string and value-string.
(define (regex-unescaped-char char-string) ;; … basically splits the string along the first unescaped colon (:).
`(: (neg-look-behind "\\") ,char-string))
;; Splits a line into a list of key/value pairs.
(define (split-vcard-line line) (define (split-vcard-line line)
(let [(split (irregex-split (regex-unescaped-char ":") line))] (let [(split (irregex-extract "(\\\\:|[^:])*" line))]
(if (>= (length split) 2) (if (>= (length split) 2)
(cons (cons
(car split) (car split)