Fixed #32814 -- Improved performance of TextNode.

This avoids calling render() and handling exceptions, which is not
necessary for text nodes.
This commit is contained in:
Keryn Knight 2021-06-07 20:02:00 +01:00 committed by GitHub
parent bbf09254a3
commit 7f6a41d3d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -520,6 +520,7 @@ answer newbie questions, and generally made Django that much better:
Keith Bussell <kbussell@gmail.com>
Kenneth Love <kennethlove@gmail.com>
Kent Hauser <kent@khauser.net>
Keryn Knight <keryn@kerynknight.com>
Kevin Grinberg <kevin@kevingrinberg.com>
Kevin Kubasik <kevin@kubasik.net>
Kevin McConnell <kevin.mcconnell@gmail.com>

View File

@ -981,6 +981,15 @@ class TextNode(Node):
def render(self, context):
return self.s
def render_annotated(self, context):
"""
Return the given value.
The default implementation of this method handles exceptions raised
during rendering, which is not necessary for text nodes.
"""
return self.s
def render_value_in_context(value, context):
"""