mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Speed up the qhash implementation
This commit is contained in:
parent
c893f0de7e
commit
3ab5097788
@ -31,19 +31,19 @@ from calibre.utils.config_base import prefs
|
|||||||
EPUB_EXT = '.epub'
|
EPUB_EXT = '.epub'
|
||||||
|
|
||||||
|
|
||||||
# Implementation of QtQHash for strings. This doesn't seem to be in the Python implemention.
|
# Implementation of QtQHash for strings. This doesn't seem to be in the Python implementation.
|
||||||
def qhash (inputstr):
|
def qhash(inputstr):
|
||||||
instr = ""
|
instr = b""
|
||||||
if isinstance (inputstr, str):
|
if isinstance(inputstr, bytes):
|
||||||
instr = inputstr
|
instr = inputstr
|
||||||
elif isinstance (inputstr, unicode):
|
elif isinstance(inputstr, unicode):
|
||||||
instr = inputstr.encode ("utf8")
|
instr = inputstr.encode("utf8")
|
||||||
else:
|
else:
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
h = 0x00000000
|
h = 0x00000000
|
||||||
for i in range (0, len (instr)):
|
for x in bytearray(instr):
|
||||||
h = (h << 4) + ord(instr[i])
|
h = (h << 4) + x
|
||||||
h ^= (h & 0xf0000000) >> 23
|
h ^= (h & 0xf0000000) >> 23
|
||||||
h &= 0x0fffffff
|
h &= 0x0fffffff
|
||||||
|
|
||||||
@ -1251,7 +1251,7 @@ class KOBOTOUCH(KOBO):
|
|||||||
|
|
||||||
max_supported_fwversion = (2,9,1)
|
max_supported_fwversion = (2,9,1)
|
||||||
min_fwversion_images_on_sdcard = (2,4,1)
|
min_fwversion_images_on_sdcard = (2,4,1)
|
||||||
min_fwversion_images_tree = (2,9,0) # Cover images stored in tree under .kobo-images
|
min_fwversion_images_tree = (2,9,0) # Cover images stored in tree under .kobo-images
|
||||||
|
|
||||||
has_kepubs = True
|
has_kepubs = True
|
||||||
|
|
||||||
@ -1764,8 +1764,8 @@ class KOBOTOUCH(KOBO):
|
|||||||
bookshelves = get_bookshelvesforbook(connection, row[3])
|
bookshelves = get_bookshelvesforbook(connection, row[3])
|
||||||
|
|
||||||
prefix = self._card_a_prefix if oncard == 'carda' else self._main_prefix
|
prefix = self._card_a_prefix if oncard == 'carda' else self._main_prefix
|
||||||
changed = update_booklist(prefix, path, row[0], row[1], mime, row[2], row[3], row[5],
|
changed = update_booklist(prefix, path, row[0], row[1], mime, row[2], row[3], row[5],
|
||||||
row[6], row[7], row[4], row[8], row[9], row[10], row[11],
|
row[6], row[7], row[4], row[8], row[9], row[10], row[11],
|
||||||
row[12], row[13], row[14], bookshelves)
|
row[12], row[13], row[14], bookshelves)
|
||||||
|
|
||||||
if changed:
|
if changed:
|
||||||
@ -2042,7 +2042,7 @@ class KOBOTOUCH(KOBO):
|
|||||||
if os.path.exists(fpath):
|
if os.path.exists(fpath):
|
||||||
debug_print("KoboTouch:delete_images - Image File Exists")
|
debug_print("KoboTouch:delete_images - Image File Exists")
|
||||||
os.unlink(fpath)
|
os.unlink(fpath)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.removedirs(os.path.dirname(path))
|
os.removedirs(os.path.dirname(path))
|
||||||
except:
|
except:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user