From: Edi Weitz
Subject: Re: Compile time creation of cl-ppcre scanner in let
Date:
Message-ID: <uy7b24iu7.fsf@agharta.de>
On Sun, 6 Jan 2008 15:38:27 -0800 (PST), Slobodan Blazeski <·················@gmail.com> wrote:
> Why isn't scanner created in the let form at compile time
Why should it?
--
European Common Lisp Meeting, Amsterdam, April 19/20, 2008
http://weitz.de/eclm2008/
Real email: (replace (subseq ·········@agharta.de" 5) "edi")
P� Mon, 07 Jan 2008 00:38:27 +0100, skrev Slobodan Blazeski
<·················@gmail.com>:
> Why isn't scanner created in the let form at compile time , instead of
> recreating it for each call of email-let-fix?
> http://paste.lisp.org/display/53728
> (defvar *email* ··················@gmail.com")
>
> (defun email-let-fix (email)
> (let ((scanner (cl-ppcre:create-scanner
> ··················@gmail.com")))
> (cl-ppcre:scan scanner email)))
> EMAIL-LET-FIX
>
Because you create one each time you call the function.
Always move the creation of the scanner outside the loop if it doesn't
change.
(It doesn't have to be special)
--------------
John Thingstad
Stupid me, I should have coded the clozure as:
(let ((scanner (cl-ppcre:create-scanner
··················@gmail.com")))
(defun email-let-fix (email)
(cl-ppcre:scan scanner email)))
EMAIL-LET-FIX
now everything is great.
(time (test 10000 #'email-let-fix *email*))
Timing the evaluation of (TEST 10000 (FUNCTION EMAIL-LET-FIX) *EMAIL*)
User time = 0.160
System time = 0.000
Elapsed time = 0.511
Allocation = 3445392 bytes
0 Page faults
Calls to %EVAL 30034
NIL
cheers
Slobodan
From: Edi Weitz
Subject: Re: Compile time creation of cl-ppcre scanner in let
Date:
Message-ID: <umyri1lgy.fsf@agharta.de>
On Sun, 6 Jan 2008 16:02:42 -0800 (PST), Slobodan Blazeski <·················@gmail.com> wrote:
> Stupid me, I should have coded the clozure as:
> (let ((scanner (cl-ppcre:create-scanner ··················@gmail.com")))
> (defun email-let-fix (email)
> (cl-ppcre:scan scanner email)))
> EMAIL-LET-FIX
This
(defun email-let-fix (email)
(ppcre:scan ··················@gmail.com" email))
should have the same effect if the function is compiled. See the
compiler macros in api.lisp.
Edi.
--
European Common Lisp Meeting, Amsterdam, April 19/20, 2008
http://weitz.de/eclm2008/
Real email: (replace (subseq ·········@agharta.de" 5) "edi")
On Jan 7, 2:19 am, Edi Weitz <········@agharta.de> wrote:
> On Sun, 6 Jan 2008 16:02:42 -0800 (PST), Slobodan Blazeski <·················@gmail.com> wrote:
> > Stupid me, I should have coded the clozure as:
> > (let ((scanner (cl-ppcre:create-scanner ··················@gmail.com")))
> > (defun email-let-fix (email)
> > (cl-ppcre:scan scanner email)))
> > EMAIL-LET-FIX
>
> This
>
> (defun email-let-fix (email)
> (ppcre:scan ··················@gmail.com" email))
>
> should have the same effect if the function is compiled. See the
> compiler macros in api.lisp.
>
I decided to defparameter the scanner so the user could easily change
it's own regex if it doesn't like mine.
Thanks for your advice.
cheers
Slobodan
> Edi.
>
> --
>
> European Common Lisp Meeting, Amsterdam, April 19/20, 2008
>
> http://weitz.de/eclm2008/
>
> Real email: (replace (subseq ·········@agharta.de" 5) "edi")