]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Small optimizations for escape branches
authorArmin Ronacher <armin.ronacher@active-4.com>
Tue, 3 Jan 2017 00:57:12 +0000 (01:57 +0100)
committerArmin Ronacher <armin.ronacher@active-4.com>
Tue, 3 Jan 2017 22:45:30 +0000 (23:45 +0100)
jinja2/compiler.py

index 162e73ade54e677e856e40e33803068c841a5769..ef3da7bed5dfa89f6f4e980cfe30efd8e3863a9b 100644 (file)
@@ -1100,8 +1100,8 @@ class CodeGenerator(NodeVisitor):
                         self.newline(item)
                     close = 1
                     if frame.eval_ctx.volatile:
-                        self.write('(context.eval_ctx.autoescape and'
-                                   ' escape or to_string)(')
+                        self.write('(escape if context.eval_ctx.autoescape'
+                                   ' else to_string)(')
                     elif frame.eval_ctx.autoescape:
                         self.write('escape(')
                     else:
@@ -1138,8 +1138,8 @@ class CodeGenerator(NodeVisitor):
                 self.newline(argument)
                 close = 0
                 if frame.eval_ctx.volatile:
-                    self.write('(context.eval_ctx.autoescape and'
-                               ' escape or to_string)(')
+                    self.write('(escape if context.eval_ctx.autoescape else'
+                               ' to_string)(')
                     close += 1
                 elif frame.eval_ctx.autoescape:
                     self.write('escape(')
@@ -1241,7 +1241,7 @@ class CodeGenerator(NodeVisitor):
         try:
             self.write(repr(node.as_const(frame.eval_ctx)))
         except nodes.Impossible:
-            self.write('(context.eval_ctx.autoescape and Markup or identity)(%r)'
+            self.write('(Markup if context.eval_ctx.autoescape else identity)(%r)'
                        % node.data)
 
     def visit_Tuple(self, node, frame):