diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-05-09 22:19:01 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2020-05-09 22:19:01 +0200 |
commit | f56daa40756cb4f356c283567de9cbc050bd86b1 (patch) | |
tree | 778a1bbada2a00acc854a85721f36618b6ce4f6b /module/util | |
parent | Clean up util header. (diff) | |
parent | Add short commentary on difference between parse and parse/component. (diff) | |
download | calp-f56daa40756cb4f356c283567de9cbc050bd86b1.tar.gz calp-f56daa40756cb4f356c283567de9cbc050bd86b1.tar.xz |
Replace iCalendar parser.
The old iCalendar parser was a direct port of my C parser, which
unfortunately clashed with guile's evaluation model, and was therefore
really slow.
This new one is much schemier [sic?], and therefore much faster. On my
laptop the parse time went from around 10s to 2.5s, so a 4x speedup!
Diffstat (limited to '')
-rw-r--r-- | module/util/exceptions.scm | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/module/util/exceptions.scm b/module/util/exceptions.scm index 41efaff5..4673b182 100644 --- a/module/util/exceptions.scm +++ b/module/util/exceptions.scm @@ -2,7 +2,8 @@ #:use-module (srfi srfi-1) #:use-module (util) #:export (throw-returnable - catch-multiple)) + catch-multiple + assert)) (define-syntax-rule (throw-returnable symb args ...) (call/cc (lambda (cont) (throw symb cont args ...)))) @@ -52,3 +53,21 @@ (display (apply (warning-handler) fmt (or args '())) (current-error-port))) + +(define (prettify-tree tree) + (cond [(null? tree) '()] + [(pair? tree) (cons (prettify-tree (car tree)) + (prettify-tree (cdr tree)))] + [(list? tree) (map prettify-tree tree)] + [(and (procedure? tree) + (procedure-name tree)) + => identity] + [else tree])) + + + +(define-macro (assert form) + `(unless ,form + (throw 'assertion-error "Assertion for ~a failed, ~a" + (quote ,form) + ((@@ (util exceptions) prettify-tree) ,(cons 'list form))))) |