diff options
author | Lucas Hoffmann <l-m-h@web.de> | 2017-07-06 13:13:39 +0200 |
---|---|---|
committer | Lucas Hoffmann <l-m-h@web.de> | 2017-07-06 13:13:39 +0200 |
commit | 2975d18c7233ef2a816f5a480b9065f851489cf3 (patch) | |
tree | 958053e629a8888c9586e402861de971e7b78a2e /alot/addressbook | |
parent | 9a74beba9a6fc827482834fadbab8d2e20fa1acb (diff) |
Compile regex outside of for loop
Diffstat (limited to 'alot/addressbook')
-rw-r--r-- | alot/addressbook/__init__.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/alot/addressbook/__init__.py b/alot/addressbook/__init__.py index fbd95a99..f30c7274 100644 --- a/alot/addressbook/__init__.py +++ b/alot/addressbook/__init__.py @@ -34,9 +34,8 @@ class AddressBook(object): def lookup(self, query=''): """looks up all contacts where name or address match query""" res = [] - query = '.*%s.*' % query + query = re.compile('.*%s.*' % query, self.reflags) for name, email in self.get_contacts(): - if re.match(query, name, self.reflags) or \ - re.match(query, email, self.reflags): + if query.match(name) or query.match(email): res.append((name, email)) return res |