[cl-ppcre-devel] Re: Question: PCRE -> Thompson NFA Implementation

Edi Weitz edi at agharta.de
Wed Feb 14 08:35:31 UTC 2007


On Tue, 13 Feb 2007 21:08:33 -0800, Brent Fulgham <bfulg at pacbell.net> wrote:

> The implementations are all written by volunteers who submit them.
> If you see any low hanging fruit, let me know and I'll be glad to
> update the tests.

For example here's a more compact (and most likely faster) way to read
a whole file at once (untested):

  (defun get-input-chars (stream)
    (let ((result (make-string (file-length stream))))
      (read-sequence result stream)
      result))

See also <http://www.emmett.ca/~sabetts/slurp.html>.

It probably won't change the outcome of the benchmark, but the
original function looks pretty weird.

Also, if you're really obsessed with speed, CL-PPCRE:ALL-MATCHES
certainly isn't the best way to count all matches because it conses up
a list you don't need.  You should use DO-SCANS and count yourself.

Finally, I think that ">[^\\n]*\\n|\\n" should be replaced by
"(?m)\\n|^>.*" - maybe not for speed, but for clarity and correctness.

> But of course, the tests are all for entertainment purposes only ;-)

Yes... :)



More information about the Cl-ppcre-devel mailing list