Optimizations by Campbell, thanks!
This commit is contained in:
@@ -155,21 +155,20 @@ class UI_UL_list(bpy.types.UIList):
|
|||||||
"""
|
"""
|
||||||
import fnmatch
|
import fnmatch
|
||||||
|
|
||||||
if not pattern: # Empty pattern = no filtering!
|
if not pattern or not items: # Empty pattern or list = no filtering!
|
||||||
return flags or []
|
return flags or []
|
||||||
|
|
||||||
if flags is None:
|
if flags is None:
|
||||||
flags = [0] * len(items)
|
flags = [0] * len(items)
|
||||||
for idx, it in enumerate(items):
|
|
||||||
name = getattr(it, propname, None)
|
# Implicitly add heading/trailing wildcards.
|
||||||
# Implicitly add heading/trailing wildcards if needed.
|
pattern = "*" + pattern + "*"
|
||||||
if pattern[0] != "*":
|
|
||||||
pattern = "*" + pattern
|
for i, item in enumerate(items):
|
||||||
if pattern[-1] != "*":
|
name = getattr(item, propname, None)
|
||||||
pattern = pattern + "*"
|
|
||||||
# This is similar to a logical xor
|
# This is similar to a logical xor
|
||||||
if bool(name and fnmatch.fnmatch(name.lower(), pattern.lower())) is not bool(reverse):
|
if bool(name and fnmatch.fnmatchcase(name, pattern)) is not bool(reverse):
|
||||||
flags[idx] |= bitflag
|
flags[i] |= bitflag
|
||||||
return flags
|
return flags
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Reference in New Issue
Block a user