[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Axiom-developer] A first attempt at a notangle in Lisp
From: |
Gregory Vanuxem |
Subject: |
Re: [Axiom-developer] A first attempt at a notangle in Lisp |
Date: |
Fri, 16 Feb 2007 17:59:15 +0100 |
Le vendredi 16 février 2007 à 13:44 +0100, Waldek Hebisch a écrit :
> > I hesitate to say it's useful, but I have what appears to be a (more or
> > less) working notangle command in lisp. It successfully handles a
> > couple test files, and although I haven't inspected the results it
> > handled most of the contents of boot and interp without crashing.
> > Unfortunately it's performance is worse than abysmal.
>
> Your method of appending content to a chunk was quadratic. Below
> is a diff changing this to linear method, gives much better speed (at
> least on "nag-e02.boot.pamphlet") but still much slower than Debian
> notangle (0.48s sbcl, 0.028s system version). AFAICS reading
> pamphlets is still slow (takes 0.4s on "nag-e02.boot.pamphlet").
>
>
> --- cl-notangle.lisp.pamphlet 2007-02-16 11:57:23.000000000 +0100
> +++ cl-notangle.lisp.pamphlet 2007-02-16 13:03:47.000000000 +0100
> @@ -365,13 +365,21 @@
>
> <<readin-chunk>>=
> (defun read-in-chunk (curr-chunk-name filename)
> - (let ((nextline (read-line filename nil)))
> - (if (or (not (search endchunkchars nextline))
> - (search (concatenate 'string (string #\") endchunkchars)
> - nextline))
> - (progn
> - (add-to-chunk-contents curr-chunk-name nextline)
> - (read-in-chunk curr-chunk-name filename)))))
> + (let ((lines nil))
> + (loop for nextline = (read-line filename nil)
> + while (or (not (search endchunkchars nextline))
> + (search (concatenate 'string (string #\")
> endchunkchars)
> + nextline))
> + do
> + (progn
> + (push nextline lines)
> + (push (string #\Newline) lines)))
> + (if lines
> + (progn
> + (pop lines)
> + (add-to-chunk-contents curr-chunk-name
> + (apply #'concatenate 'string
> + (reverse lines)))))))
And another one (it does not remove the last #\Newline):
(defun read-in-chunk (curr-chunk-name filename)
(let* ((nl (string #\Newline))
(lines (loop for nextline = (read-line filename nil)
while (or (not (search endchunkchars nextline))
(search (concatenate 'string (string #\")
endchunkchars)
nextline))
collect (concatenate 'string nextline nl))))
(if lines
(add-to-chunk-contents curr-chunk-name
(apply #'concatenate 'string
lines)))))
Only tested on nag-e02.boot.pamphlet with SBCL.
Greg
- Re: [Axiom-developer] A first attempt at a notangle in Lisp, (continued)
- Re: [Axiom-developer] A first attempt at a notangle in Lisp, Waldek Hebisch, 2007/02/16
- Re: [Axiom-developer] A first attempt at a notangle in Lisp, C Y, 2007/02/16
- Re: [Axiom-developer] A first attempt at a notangle in Lisp, Ralf Hemmecke, 2007/02/16
- Re: [Axiom-developer] A first attempt at a notangle in Lisp, C Y, 2007/02/16
- Re: [Axiom-developer] A first attempt at a notangle in Lisp, Ralf Hemmecke, 2007/02/16
- Re: [Axiom-developer] A first attempt at a notangle in Lisp, C Y, 2007/02/16
- Re: [Axiom-developer] A first attempt at a notangle in Lisp, Martin Rubey, 2007/02/16
- Re: [Axiom-developer] A first attempt at a notangle in Lisp, Ralf Hemmecke, 2007/02/16
- Re: [Axiom-developer] A first attempt at a notangle in Lisp, C Y, 2007/02/16
- [Axiom-developer] mmm-noweb and fontification, C Y, 2007/02/17
Re: [Axiom-developer] A first attempt at a notangle in Lisp,
Gregory Vanuxem <=