py scripts - replace bad uses of len(),

checking if the collection is True is faster since it only checks if it has at least one item, rather then going over all items.
This commit is contained in:
Campbell Barton
2012-01-02 16:18:39 +00:00
parent 2077b7e3b7
commit 77bdef4d22
3 changed files with 3 additions and 3 deletions

View File

@@ -239,7 +239,7 @@ class ClearUselessActions(Operator):
@classmethod
def poll(cls, context):
return len(bpy.data.actions) != 0
return bool(bpy.data.actions)
def execute(self, context):
removed = 0

View File

@@ -158,7 +158,7 @@ class DATA_PT_vertex_groups(MeshButtonsPanel, Panel):
row = layout.row()
row.prop(group, "name")
if ob.mode == 'EDIT' and len(ob.vertex_groups) > 0:
if ob.mode == 'EDIT' and ob.vertex_groups:
row = layout.row()
sub = row.row(align=True)

View File

@@ -219,7 +219,7 @@ class InputKeyMapPanel:
filtered_items = [kmi for kmi in km.keymap_items if filter_text in kmi.name.lower()]
if len(filtered_items) != 0:
if filtered_items:
col = layout.column()
row = col.row()