Much more efficient line-splitting
This commit is contained in:
parent
0a5ef01169
commit
ff259fe683
10
vcarded.scm
10
vcarded.scm
|
@ -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)
|
||||
|
|
Ŝarĝante…
Reference in New Issue