On Fri, Aug 02, 2002 at 02:08:25AM -0400, Paul Tremblay wrote:

> (I know I did a little test with sed, a python script, and a perl
> script, just changing the word "the" to "teh" in a huge file. Sed and
> python took about he same time, while perl was six times faster.)

This is from the perl source code (sv.c if you are interested):

    /* Here is some breathtakingly efficient cheating */

            if (rslen) {
                while (cnt > 0) {                    /* this     |  eat */
                    cnt--;
                    if ((*bp++ = *ptr++) == rslast)  /* really   |  dust */
                        goto thats_all_folks;        /* screams  |  sed :-) */
                }
            }
            else {
                Copy(ptr, bp, cnt, char);            /* this     |  eat */
                bp += cnt;                           /* screams  |  dust */
                ptr += cnt;                          /* louder   |  sed :-) */
                cnt = 0;
            }


-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to