mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Make memory usage minimization optional, thereby achieving an upto 10x speedup.
This commit is contained in:
parent
bf5b924058
commit
f3080a42b0
@ -218,6 +218,8 @@ def option_parser(usage):
|
||||
help='''Be verbose while processing''')
|
||||
debug.add_option('--lrs', action='store_true', dest='lrs', \
|
||||
help='Convert to LRS', default=False)
|
||||
parser.add_option('--minimize-memory-usage', action='store_true', default=False,
|
||||
help=_('Minimize memory usage at the cost of longer processing times. Use this option if you are on a memory constrained machine.'))
|
||||
return parser
|
||||
|
||||
def find_custom_fonts(options, logger):
|
||||
|
@ -648,8 +648,7 @@ class HTMLConverter(object):
|
||||
# Need to make a copy of contents as when
|
||||
# extract is called on a child, it will
|
||||
# mess up the iteration.
|
||||
contents = [i for i in ptag.contents]
|
||||
for c in contents:
|
||||
for c in copy.copy(ptag.contents):
|
||||
if isinstance(c, HTMLConverter.IGNORED_TAGS):
|
||||
continue
|
||||
elif isinstance(c, Tag):
|
||||
@ -658,7 +657,8 @@ class HTMLConverter(object):
|
||||
self.add_text(c, pcss, ppcss)
|
||||
if not self.in_table:
|
||||
try:
|
||||
ptag.extract()
|
||||
if self.minimize_memory_usage:
|
||||
ptag.extract()
|
||||
except AttributeError:
|
||||
print ptag, type(ptag)
|
||||
|
||||
@ -1532,8 +1532,9 @@ class HTMLConverter(object):
|
||||
self.logger.debug('Bad table:\n%s', str(tag)[:300])
|
||||
self.in_table = False
|
||||
self.process_children(tag, tag_css, tag_pseudo_css)
|
||||
finally:
|
||||
tag.extract()
|
||||
finally:
|
||||
if self.minimize_memory_usage:
|
||||
tag.extract()
|
||||
else:
|
||||
self.process_children(tag, tag_css, tag_pseudo_css)
|
||||
if end_page:
|
||||
|
Loading…
x
Reference in New Issue
Block a user