database: improve ns_contains method
It isn't necessary to read out the entire namespace, just attempt to fetch the record and reduce the key list. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
43c1b998b0
commit
e754d123dd
|
@ -406,10 +406,11 @@ class MoonrakerDatabase:
|
|||
with self.thread_lock:
|
||||
try:
|
||||
key_list = self._process_key(key)
|
||||
record = self._get_record(namespace, key_list[0])
|
||||
if len(key_list) == 1:
|
||||
return key_list[0] in self.ns_keys(namespace)
|
||||
ns = self._get_namespace(namespace)
|
||||
reduce(operator.getitem, key_list[1:], ns)
|
||||
return True
|
||||
reduce(operator.getitem, # type: ignore
|
||||
key_list[1:], record)
|
||||
except Exception:
|
||||
return False
|
||||
return True
|
||||
|
|
Loading…
Reference in New Issue