[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: help to get this running faster
From: |
Karl M. Hegbloom |
Subject: |
Re: help to get this running faster |
Date: |
04 Sep 2000 18:53:30 -0700 |
>>>>> "Brad" == Brad Knotwell <address@hidden> 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.