summaryrefslogtreecommitdiff
path: root/kconfiglib.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2018-10-31 04:18:41 +0100
committerUlf Magnusson <foo@bar.com>2018-11-01 01:18:38 +0100
commitd30b55043c4c771cdabf42847cf718a93cf86ab8 (patch)
tree942afac98171131bcc589766e1477c60496cfc95 /kconfiglib.py
parentdbd07bb85db0448502ee51aa43ea6ca27b84ed45 (diff)
Refactor _remove_ifs()
Can get away with a single variable by assigning node.list earlier, and save a tiny bit of work with a chained assignment. Also clarify what the tricky Python chained assignments correspond to, where it matters.
Diffstat (limited to 'kconfiglib.py')
-rw-r--r--kconfiglib.py30
1 files changed, 21 insertions, 9 deletions
diff --git a/kconfiglib.py b/kconfiglib.py
index 116eca7..1e320a5 100644
--- a/kconfiglib.py
+++ b/kconfiglib.py
@@ -2486,7 +2486,12 @@ class Kconfig(object):
self._warn("the menuconfig symbol {} has no prompt"
.format(_name_and_loc(sym)))
- # Tricky Python semantics: This assigns prev.next before prev
+ # Equivalent to
+ #
+ # prev.next = node
+ # prev = node
+ #
+ # due to tricky Python semantics. The order matters.
prev.next = prev = node
elif t0 is None:
@@ -5804,17 +5809,24 @@ def _remove_ifs(node):
# doesn't bother to do this, but we expose the menu tree directly, and it
# makes it nicer to work with.
- first = node.list
- while first and not first.item:
- first = first.next
+ cur = node.list
+ while cur and not cur.item:
+ cur = cur.next
+
+ node.list = cur
- cur = first
while cur:
if cur.next and not cur.next.item:
- cur.next = cur.next.next
- cur = cur.next
-
- node.list = first
+ # Equivalent to
+ #
+ # tmp = cur.next.next
+ # cur.next = tmp
+ # cur = tmp
+ #
+ # due to tricky Python semantics. The order matters.
+ cur.next = cur = cur.next.next
+ else:
+ cur = cur.next
def _finalize_choice(node):
# Finalizes a choice, marking each symbol whose menu node has the choice as