diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2019-12-22 08:13:02 +0100 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2019-12-22 08:54:50 +0100 |
| commit | 1e3926e5c65e4e01b22f9b1198caa1ae31e44c42 (patch) | |
| tree | f17d16ad8b49bc57b1230bf91c0e2161439f292f /kconfiglib.py | |
| parent | 87fab023d0121a9f27f0af8de85cedc6978af6cb (diff) | |
Remove redundant 'node.next = None' assignment for the last node in a file
A node already gets its .next pointer set in _parse_block() if it is
either
1. followed by another node, or
2. the last node in a menu, choice, or if.
This also works for nodes from 'source'd files, so there's no need to
special-case the ends of them. Remove the 'node.next = None' assignment
for ends of files.
Instead, special-case just the last node in all files, and set its .next
to None in Kconfig._init().
Unlikely to give a noticeable performance improvement. Just tightens up
the chaining logic a bit.
Diffstat (limited to 'kconfiglib.py')
| -rw-r--r-- | kconfiglib.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/kconfiglib.py b/kconfiglib.py index 6b5e99b..4be2d5c 100644 --- a/kconfiglib.py +++ b/kconfiglib.py @@ -1080,8 +1080,9 @@ class Kconfig(object): self._readline = self._open(join(self.srctree, filename), "r").readline try: - # Parse the Kconfig files - self._parse_block(None, self.top_node, self.top_node) + # Parse the Kconfig files. Returns the last node, which we + # terminate with '.next = None'. + self._parse_block(None, self.top_node, self.top_node).next = None self.top_node.list = self.top_node.next self.top_node.next = None except UnicodeDecodeError as e: @@ -3086,7 +3087,7 @@ class Kconfig(object): "no corresponding 'menu'" if t0 is _T_ENDMENU else "unrecognized construct") - # End of file reached. Terminate the final node and return it. + # End of file reached. Return the last node. if end_token: raise KconfigError( @@ -3096,7 +3097,6 @@ class Kconfig(object): "endmenu", self.filename)) - prev.next = None return prev def _parse_cond(self): |
