From 56b9ceed1085b2e004e4f9c1ecef4e4de83303b7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 7 Apr 2009 09:01:06 -0700 Subject: [PATCH] Speed up adding books to an already large collection --- src/calibre/library/database2.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index 999a242986..6ccfd6de67 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -622,7 +622,11 @@ class LibraryDatabase2(LibraryDatabase): if title: if not isinstance(title, unicode): title = title.decode(preferred_encoding, 'replace') - return bool(self.conn.get('SELECT id FROM books where title=?', (title,), all=False)) + tf = FIELD_MAP['title'] + q = title.lower() + for record in self.data._data: + if record is not None and record[tf].lower() == q: + return True return False def has_cover(self, index, index_is_id=False):