Hi,

I was expecting that string-substitute* is
faster than calling multiple string-substitute's.

But a simple test showed me the opposite result.
Any ideas?

BTW, string-substitute* does not have the optional argument INDEX,
which string-substitute has. What's the default behavior?

Daishi

(define (my-string-substitute* str smap)
  (let loop ([str str] [smap smap])
    (if (null? smap)
        str
        (loop (string-substitute (caar smap) (cdar smap) str #f) (cdr smap)))))

#;2> (time (doit))
   3.584 seconds elapsed
     2.7 seconds in (major) GC
    3274 mutations
       1 minor GCs
     187 major GCs
#;3> (set! my-string-substitute* string-substitute*)
#;4> (time (doit))
  27.782 seconds elapsed
  15.578 seconds in (major) GC
    8220 mutations
       2 minor GCs
    1179 major GCs


_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to