Speed up convert_literalparam. Part of #11200.

This commit is contained in:
Richard Kimberly Heck 2018-07-21 22:49:49 -04:00
parent 8573391aee
commit 4549f46a43

View File

@ -1502,12 +1502,16 @@ command_insets = ["bibitem", "citation", "href", "index_print", "nomenclature"]
def convert_literalparam(document):
" Add param literal "
for inset in command_insets:
pos = len("\\begin_inset CommandInset ")
i = 0
while True:
i = find_token(document.body, '\\begin_inset CommandInset %s' % inset, i)
i = find_token(document.body, '\\begin_inset CommandInset', i)
if i == -1:
break
inset = document.body[i][pos:].strip()
if not inset in command_insets:
i += 1
continue
j = find_end_of_inset(document.body, i)
if j == -1:
document.warning("Malformed LyX document: Can't find end of %s inset at line %d" % (inset, i))
@ -1520,6 +1524,7 @@ def convert_literalparam(document):
document.body.insert(i, "literal \"false\"")
else:
document.body.insert(i, "literal \"true\"")
i = j + 1
def revert_literalparam(document):