[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43078] trunk/blender/release/scripts/ startup: py scripts - replace bad uses of len(),

Campbell Barton ideasman42 at gmail.com
Mon Jan 2 17:18:43 CET 2012


Revision: 43078
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43078
Author:   campbellbarton
Date:     2012-01-02 16:18:39 +0000 (Mon, 02 Jan 2012)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_operators/anim.py
    trunk/blender/release/scripts/startup/bl_ui/properties_data_mesh.py
    trunk/blender/release/scripts/startup/bl_ui/space_userpref_keymap.py

Modified: trunk/blender/release/scripts/startup/bl_operators/anim.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_operators/anim.py	2012-01-02 15:57:33 UTC (rev 43077)
+++ trunk/blender/release/scripts/startup/bl_operators/anim.py	2012-01-02 16:18:39 UTC (rev 43078)
@@ -239,7 +239,7 @@
 
     @classmethod
     def poll(cls, context):
-        return len(bpy.data.actions) != 0
+        return bool(bpy.data.actions)
 
     def execute(self, context):
         removed = 0

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_data_mesh.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_data_mesh.py	2012-01-02 15:57:33 UTC (rev 43077)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_data_mesh.py	2012-01-02 16:18:39 UTC (rev 43078)
@@ -158,7 +158,7 @@
             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)

Modified: trunk/blender/release/scripts/startup/bl_ui/space_userpref_keymap.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_userpref_keymap.py	2012-01-02 15:57:33 UTC (rev 43077)
+++ trunk/blender/release/scripts/startup/bl_ui/space_userpref_keymap.py	2012-01-02 16:18:39 UTC (rev 43078)
@@ -219,7 +219,7 @@
 
             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()



More information about the Bf-blender-cvs mailing list