py scripts - replace bad uses of len(),
authorCampbell Barton <ideasman42@gmail.com>
Mon, 2 Jan 2012 16:18:39 +0000 (16:18 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 2 Jan 2012 16:18:39 +0000 (16:18 +0000)
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.

release/scripts/startup/bl_operators/anim.py
release/scripts/startup/bl_ui/properties_data_mesh.py
release/scripts/startup/bl_ui/space_userpref_keymap.py

index 01103aede0da17cd322296d34e82cf87b5962195..29e8a3960882a19ca0b241f3a4be26c50f99f898 100644 (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
index fa59cc0ac534c5567e5824e0a2708473310d8a53..710b49618e9dff3031887940e062b06913ecbb8b 100644 (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)
index d738e806320a5cc21b7a1dc15be3f82344bf7923..6fa3aabaeb81be90696332df6c4251535941fc34 100644 (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()