changeset 959:2a45c61aedbc experimental-performance-improvement-exploration

Move push and pop outside the loop in the ForDirective since it's equivalent to just pushing and popping on the edges.
author hodgestar
date Tue, 13 Mar 2012 08:01:05 +0000
parents 6fc92535c888
children 008637942dd4
files genshi/template/directives.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/genshi/template/directives.py
+++ b/genshi/template/directives.py
@@ -378,13 +378,13 @@
 
         assign = self.assign
         scope = {}
+        ctxt.push(scope)
         stream = list(stream)
         for item in iterable:
             assign(scope, item)
-            ctxt.push(scope)
             for event in _apply_directives(stream, directives, ctxt, vars):
                 yield event
-            ctxt.pop()
+        ctxt.pop()
 
     def __repr__(self):
         return '<%s>' % type(self).__name__
Copyright (C) 2012-2017 Edgewall Software