This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
Re: help to get this running faster
- To: Brad Knotwell <knotwell at ix dot netcom dot com>
- Subject: Re: help to get this running faster
- From: karlheg at bittersweet dot inetarena dot com (Karl M. Hegbloom)
- Date: 04 Sep 2000 18:53:30 -0700
- Cc: guile-user at gnu dot org
- List-Id: <guile-user.gnu.org>
- References: <200009030352.UAA01306@ix.netcom.com>
>>>>> "Brad" == Brad Knotwell <knotwell@ix.netcom.com> writes:
Brad> Hello--
Brad> It's not exactly the same script, but I think it does pretty much the same
Brad> thing (I changed from a set of nested lists (???) to a single list).
Brad> On my machine, it's an order of magnitude faster than the previous
Brad> script.
Brad> (define-module (alto tabreader))
Brad> (export load-records)
Brad> (use-modules (ice-9 optargs))
Brad> (use-modules (ice-9 string-fun)
Brad> (define* (load-records fname #&optional (sep #\tab))
Brad> (call-with-input-file fname
Brad> (lambda (i-stream)
Brad> (do ((records '())
Brad> (line (read-line i-stream) (read-line i-stream)))
Brad> ((eof-object? line) records)
Brad> (set! records (append records (list (split-discarding-char sep line list))))))))
Rather than using `append' like that, I would use `cons', and finally
return `(reverse! records)'. I think that would be faster.
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user