Skip to content

Commit 09e14b6

Browse files
committed
Memoize kind in Simplesect Node
Rather than repeatedly loading the kind from the node's attributes, fetch it once and then switch on the resulting value multiple times.
1 parent c7096f1 commit 09e14b6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

nodes.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,9 @@ class SimplesectNode(Node):
645645
def to_asciidoc(self, **kwargs):
646646
previous_node = self.previous_node()
647647
next_node = self.next_node()
648-
if self.node.get("kind") == "see":
648+
kind = self.node.get("kind")
649+
650+
if kind == "see":
649651
output = []
650652
if not (
651653
previous_node
@@ -662,10 +664,10 @@ def to_asciidoc(self, **kwargs):
662664
output.append("\n--")
663665
return "".join(output)
664666

665-
if self.node.get("kind") == "return":
667+
if kind == "return":
666668
return f"--\n*Returns*\n\n{super().to_asciidoc(**kwargs)}\n--"
667669

668-
if self.node.get("kind") == "note":
670+
if kind == "note":
669671
output = []
670672
if not (
671673
previous_node

0 commit comments

Comments
 (0)