libsaria: Turn get_attrs_id into a function pointer
I was doing an extra python lookup every time this function was used. Turning it into a function pointer should cut down on this.
This commit is contained in:
parent
756c98285b
commit
38b075a701
|
@ -37,13 +37,13 @@ def inc_count():
|
|||
# This will eventually increment a play count...
|
||||
pass
|
||||
|
||||
def get_attrs_id(id, *attrs):
|
||||
return library.get_attrs(id, *attrs)
|
||||
# Function pointer to avoid unnecessary lookups for a common function
|
||||
get_attrs_id = library.get_attrs
|
||||
|
||||
def get_attrs(*attrs):
|
||||
# I should probably get a lock here...
|
||||
if cur_id:
|
||||
return library.get_attrs(cur_id, *attrs)
|
||||
return get_attrs_id(cur_id, *attrs)
|
||||
return -1
|
||||
|
||||
def filter(text):
|
||||
|
@ -87,10 +87,9 @@ def next():
|
|||
|
||||
def list_source(list_func, *attrs):
|
||||
ret = []
|
||||
get_attrs = library.get_attrs
|
||||
append = ret.append
|
||||
for id in list_func():
|
||||
append(get_attrs(id, *attrs))
|
||||
append(get_attrs_id(id, *attrs))
|
||||
return ret
|
||||
|
||||
def list_library(*attrs):
|
||||
|
|
Loading…
Reference in New Issue