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

Re: 6-pws-2



On Aug 31, 10:22am, Sven Wischnowsky wrote:
} Subject: Re: 6-pws-2
}
} 2) probably add caches for parsed patterns (e.g. give patcompile() an
}    optional pointer to a patcache struct which would contain the
}    strings and compiled pattern of the last few patterns used at the
}    call site and make patcompile() first look there)

The cache lookup would have to be awfully fast to make it worthwhile.
I think we'd get a lot more benefit from this:

} 3) store compiled patterns in the execution tree (for now I'm only
}    thinking about `case', `[[ .. = .. ]]' and `[[ .. != .. ]]' if the
}    patterns don't need to be singsub()ed, which could be checked at
}    parse time)

... but even there it'll mostly help loops, not one-pass sorts of things
like sourcing init files.

The ideal thing might be to "incrementally" compile the pattern; do just
enough to start discarding strings that can't possibly match, then do a
bit more upon finding one that might, etc., so parsing and compiling the
full pattern requires encountering the first successful match (unless it's
a really intractible pattern).  Master's theses have been written on less
interesting problems ... you aren't looking to get a paper out of this,
are you, Peter?

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



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