TXT Input: Speed up removal of leading whitespace. Fixes #1965443 ["Remove indents at beginning of lines" sometimes greatly slow down conversion](https://bugs.launchpad.net/calibre/+bug/1965443)

This commit is contained in:
Kovid Goyal 2022-03-18 10:55:41 +05:30
parent 3627a442be
commit 4225ab51a5
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -220,7 +220,7 @@ def remove_indents(txt):
'''
Remove whitespace at the beginning of each line.
'''
return '\n'.join(l.lstrip() for l in txt.splitlines())
return re.sub(r'^\s+', '', txt, flags=re.MULTILINE)
def opf_writer(path, opf_name, manifest, spine, mi):