From 4ea6a040fb849a00e12065452942373223c56ba0 Mon Sep 17 00:00:00 2001 From: Izalia Mae Date: Fri, 18 Nov 2022 14:36:30 -0500 Subject: [PATCH] optimize RelayDatabase.get_inbox --- relay/database.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/relay/database.py b/relay/database.py index b79c0aa..975174d 100644 --- a/relay/database.py +++ b/relay/database.py @@ -120,13 +120,13 @@ class RelayDatabase(dict): if domain.startswith('http'): domain = urlparse(domain).hostname - if domain not in self['relay-list']: - if fail: - raise KeyError(domain) + inbox = self['relay-list'].get(domain) - return + if inbox: + return inbox - return self['relay-list'][domain] + if fail: + raise KeyError(domain) def add_inbox(self, inbox, followid=None, fail=False):