summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--src/guile/skribilo/runtime.scm24
2 files changed, 31 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 6e37524..083fff6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,20 @@
# arch-tag: automatic-ChangeLog--lcourtes@laas.fr--2005-mobile/skribilo--devel--1.2
#
+2006-02-25 13:02:20 GMT Ludovic Courtes <ludovic.courtes@laas.fr> patch-35
+
+ Summary:
+ Made `make-string-replace' faster.
+ Revision:
+ skribilo--devel--1.2--patch-35
+
+ * src/guile/skribilo/runtime.scm (%make-general-string-replace): Use a
+ hash table rather than a list.
+
+ modified files:
+ ChangeLog src/guile/skribilo/runtime.scm
+
+
2006-02-21 20:55:41 GMT Ludovic Courtes <ludovic.courtes@laas.fr> patch-34
Summary:
diff --git a/src/guile/skribilo/runtime.scm b/src/guile/skribilo/runtime.scm
index bd8497f..da5c525 100644
--- a/src/guile/skribilo/runtime.scm
+++ b/src/guile/skribilo/runtime.scm
@@ -180,13 +180,23 @@
(define (%make-general-string-replace lst)
;; The general version
- (lambda (str)
- (let ((out (open-output-string)))
- (string-for-each (lambda (ch)
- (let ((res (assq ch lst)))
- (display (if res (cadr res) ch) out)))
- str)
- (get-output-string out))))
+ (let ((chars (make-hash-table)))
+
+ ;; Setup a hash table equivalent to LST.
+ (for-each (lambda (chr)
+ (hashq-set! chars (car chr) (cadr chr)))
+ lst)
+
+ ;; Help the GC.
+ (set! lst #f)
+
+ (lambda (str)
+ (let ((out (open-output-string)))
+ (string-for-each (lambda (ch)
+ (let ((res (hashq-ref chars ch #f)))
+ (display (if res res ch) out)))
+ str)
+ (get-output-string out)))))
(define string->html
(%make-general-string-replace '((#\" "&quot;") (#\& "&amp;") (#\< "&lt;")