Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: replacement slowdown

On Apr 23, 12:26pm, Clint Adams wrote:
} > What's calling pattryrefs() 28000+ times?  Is that how many lines there
} > are in /tmp/blah?
} 231 lines, but 57093 chars.  pattrylen() seems to be called 57092 times
} by igetmatch.

OK, that makes sense.  igetmatch() has a for() loop that, when asked to
find every possible match within the string (e.g. by ${...//...}), calls
the pattern comparison once at every possible matching position.  Since
the pattern is only one character long (/,/), it calls it once for each
character in the string.

But pattry() recomputes the unmetafied length of the *entire* string on
each call.  So that length computation is going to have to be factored
out of pattry(), possibly by storing it in the Patprog the way that's
done for set_pat_start() and set_pat_end().

Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   

Messages sorted by: Reverse Date, Date, Thread, Author