diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2013-08-29 18:37:46 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2013-08-29 18:37:46 +0400 |
commit | e98ef3ae68bae2dbf05606b3baf2620500c8e132 (patch) | |
tree | d720a6e6b9528b944853d16dfb88885a9ebc1787 | |
parent | 1e613ba9c4bdb5fc279d2cf652f71a647ea54aae (diff) |
Optimizations by Campbell, thanks!
-rw-r--r-- | release/scripts/startup/bl_ui/__init__.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py index ba256bdb6c8..cecc7cba623 100644 --- a/release/scripts/startup/bl_ui/__init__.py +++ b/release/scripts/startup/bl_ui/__init__.py @@ -155,21 +155,20 @@ class UI_UL_list(bpy.types.UIList): """ import fnmatch - if not pattern: # Empty pattern = no filtering! + if not pattern or not items: # Empty pattern or list = no filtering! return flags or [] if flags is None: flags = [0] * len(items) - for idx, it in enumerate(items): - name = getattr(it, propname, None) - # Implicitly add heading/trailing wildcards if needed. - if pattern[0] != "*": - pattern = "*" + pattern - if pattern[-1] != "*": - pattern = pattern + "*" + + # Implicitly add heading/trailing wildcards. + pattern = "*" + pattern + "*" + + for i, item in enumerate(items): + name = getattr(item, propname, None) # This is similar to a logical xor - if bool(name and fnmatch.fnmatch(name.lower(), pattern.lower())) is not bool(reverse): - flags[idx] |= bitflag + if bool(name and fnmatch.fnmatchcase(name, pattern)) is not bool(reverse): + flags[i] |= bitflag return flags @staticmethod |