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