From: Martin Elster <1103.org at martin>
When I try to read a file into an array using ACL it is painfully
slow. The function I use is this:
Your algorithm is preposterously slow. First of all, omitting the
optional increment argument to vector-push-extend says you don't care
whether your algorithm is O^1 or O^2. The default in ACL6.2 is a mere
20, but that is appropriate only for code that rarely experiences
overflows. (The default has been changed in ACL 7.0 to the current
length of the array which is probably what cmucl does, but still,
depending on this kind of _unspecified_ performance behavior is
unwise. There are too many places in the definition of CL where
performance is not specified, and moreover, it is not obvious.)
The other mail reason the code is so slow is that you are doing
something char by char when the operation you are performing has no
need to pass individual characters. You could write something clever
that would use read-sequence to unroll the loop, but even smarter
would be to read the documentation and find this:
http://www.franz.com/support/documentation/6.2/doc/pages/operators/excl/file-contents.htm
A form like (file-contents "foo"" :element-type 'character) is almost
too fast to measure, since it uses the OS to map the file contents
into a newly-created string.