From 4ee8ac258518077bc9a486b5b70738ca0b07be88 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Mon, 1 Jun 2015 21:13:38 -0400 Subject: [PATCH] DB-API: Sped up get_tag_from_name --- gramps/plugins/database/dbapi.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gramps/plugins/database/dbapi.py b/gramps/plugins/database/dbapi.py index 272e713a6..5b1485d50 100644 --- a/gramps/plugins/database/dbapi.py +++ b/gramps/plugins/database/dbapi.py @@ -1058,11 +1058,11 @@ class DBAPI(DbWriteBase, DbReadBase, UpdateCallback, Callback): return (handle for handle in self.family_map.keys()) def get_tag_from_name(self, name): - ## FIXME: Slow, but typically not too many tags: - for data in self.tag_map.values(): - tag = Tag.create(data) - if tag.name == name: - return tag + cur = self.dbapi.execute("""select handle from tag where order_by = ?;""", + [self._order_by_tag_key(name)]) + row = cur.fetchone() + if row: + self.get_tag_from_handle(row[0]) return None def get_person_from_gramps_id(self, gramps_id):