This is the mail archive of the guile@sources.redhat.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: help to get this running faster


>>>>> "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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]