Mercurial > genshi > mirror
diff genshi/template/directives.py @ 704:422d0607ba85 experimental-match-fastpaths
further performance improvements to MatchSet functionality - factor out MatchSet's State so that we dont' have to keep copying over the state every time we create a new child MatchSet.
Also fixes a bug where we could get duplicate match indexes when a new match is created while evaluating an existing match
Also, try to be lazy about creating the first MatchSet so that we don't hurt bigtable performance (i.e. when there are no py:matches in play at all)
author | aflett |
---|---|
date | Fri, 04 Apr 2008 16:57:27 +0000 |
parents | af57b12e3dd2 |
children | 2a7a19861a89 |
line wrap: on
line diff
--- a/genshi/template/directives.py +++ b/genshi/template/directives.py @@ -26,6 +26,7 @@ _exec_suite from genshi.template.eval import Expression, Suite, ExpressionASTTransformer, \ _parse +from genshi.template.match import MatchSet __all__ = ['AttrsDirective', 'ChooseDirective', 'ContentDirective', 'DefDirective', 'ForDirective', 'IfDirective', 'MatchDirective', @@ -456,6 +457,10 @@ attach = classmethod(attach) def __call__(self, stream, directives, ctxt, **vars): + if ctx._match_set is None: + # lazily create MatchSet so that it doesn't burden the + # _match filter when there are no py:matches defined. + ctx._match_set = MatchSet() ctxt._match_set.add((self.path.test(ignore_context=True), self.path, list(stream), self.hints, self.namespaces, directives))