Tweaks to reduce source- and byte-code sizes

svn: r14069
This commit is contained in:
Gerald Britton 2010-01-13 20:54:46 +00:00
parent 63d9122ea2
commit d6ede10e89

View File

@ -678,8 +678,7 @@ class TreeBaseModel(gtk.GenericTreeModel):
self.remove_node(node) self.remove_node(node)
while parent is not None: while parent is not None:
next_parent = self.nodemap.node(parent.parent) \ next_parent = parent.parent and self.nodemap.node(parent.parent)
if parent.parent is not None else None
if not parent.children: if not parent.children:
if parent.handle: if parent.handle:
# emit row_has_child_toggled signal # emit row_has_child_toggled signal
@ -788,8 +787,7 @@ class TreeBaseModel(gtk.GenericTreeModel):
pathlist = list(path) pathlist = list(path)
for index in pathlist: for index in pathlist:
if self.__reverse: if self.__reverse:
size = len(node.children) node = self.nodemap.node(node.children[-index - 1][1])
node = self.nodemap.node(node.children[size - index - 1][1])
else: else:
node = self.nodemap.node(node.children[index][1]) node = self.nodemap.node(node.children[index][1])
return node return node
@ -805,8 +803,7 @@ class TreeBaseModel(gtk.GenericTreeModel):
while node is not None: while node is not None:
# Step backwards # Step backwards
nodeid = node.next if self.__reverse else node.prev nodeid = node.next if self.__reverse else node.prev
node = self.nodemap.node(nodeid) if nodeid is not None else \ node = nodeid and self.nodemap.node(nodeid)
None
index += 1 index += 1
pathlist.append(index) pathlist.append(index)
node = parent node = parent
@ -822,7 +819,7 @@ class TreeBaseModel(gtk.GenericTreeModel):
Get the next node with the same parent as the given node. Get the next node with the same parent as the given node.
""" """
val = node.prev if self.__reverse else node.next val = node.prev if self.__reverse else node.next
return self.nodemap.node(val) if val is not None else val return val and self.nodemap.node(val)
def on_iter_children(self, node): def on_iter_children(self, node):
""" """
@ -831,11 +828,8 @@ class TreeBaseModel(gtk.GenericTreeModel):
if node is None: if node is None:
node = self.tree[None] node = self.tree[None]
if node.children: if node.children:
if self.__reverse: return self.nodemap.node(
size = len(node.children) node.children[-1 if self.__reverse else 0][1])
return self.nodemap.node(node.children[size - 1][1])
else:
return self.nodemap.node(node.children[0][1])
else: else:
return None return None
@ -864,8 +858,7 @@ class TreeBaseModel(gtk.GenericTreeModel):
if node.children: if node.children:
if len(node.children) > index: if len(node.children) > index:
if self.__reverse: if self.__reverse:
size = len(node.children) return self.nodemap.node(node.children[-index - 1][1])
return self.nodemap.node(node.children[size - index - 1][1])
else: else:
return self.nodemap.node(node.children[index][1]) return self.nodemap.node(node.children[index][1])
else: else:
@ -877,5 +870,4 @@ class TreeBaseModel(gtk.GenericTreeModel):
""" """
Get the parent of the given node. Get the parent of the given node.
""" """
return self.nodemap.node(node.parent) if node.parent is not None else \ return node.parent and self.nodemap.node(node.parent)
None