mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-04 08:37:52 +00:00
Try to speed up convert_phrases by re-ordering the loops. Part of #11200.
This commit is contained in:
parent
96ea84e042
commit
8573391aee
@ -738,24 +738,24 @@ def convert_phrases(document):
|
|||||||
if document.backend != "latex":
|
if document.backend != "latex":
|
||||||
return
|
return
|
||||||
|
|
||||||
for phrase in phrases:
|
i = 0
|
||||||
i = 0
|
while i < len(document.body):
|
||||||
while i < len(document.body):
|
if document.body[i] and document.body[i][0] == "\\":
|
||||||
if document.body[i] and document.body[i][0] == "\\":
|
words = document.body[i].split()
|
||||||
words = document.body[i].split()
|
if len(words) > 1 and words[0] == "\\begin_inset" and \
|
||||||
if len(words) > 1 and words[0] == "\\begin_inset" and \
|
words[1] in ["CommandInset", "External", "Formula", "Graphics", "listings"]:
|
||||||
words[1] in ["CommandInset", "External", "Formula", "Graphics", "listings"]:
|
# must not replace anything in insets that store LaTeX contents in .lyx files
|
||||||
# must not replace anything in insets that store LaTeX contents in .lyx files
|
# (math and command insets without overridden read() and write() methods)
|
||||||
# (math and command insets without overridden read() and write() methods)
|
j = find_end_of_inset(document.body, i)
|
||||||
j = find_end_of_inset(document.body, i)
|
if j == -1:
|
||||||
if j == -1:
|
document.warning("Malformed LyX document: Can't find end of inset at line %d" % (i))
|
||||||
document.warning("Malformed LyX document: Can't find end of inset at line " + str(i))
|
|
||||||
i += 1
|
|
||||||
else:
|
|
||||||
i = j
|
|
||||||
else:
|
|
||||||
i += 1
|
i += 1
|
||||||
continue
|
else:
|
||||||
|
i = j
|
||||||
|
else:
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
for phrase in phrases:
|
||||||
j = document.body[i].find(phrase)
|
j = document.body[i].find(phrase)
|
||||||
if j == -1:
|
if j == -1:
|
||||||
i += 1
|
i += 1
|
||||||
@ -767,7 +767,7 @@ def convert_phrases(document):
|
|||||||
document.body.insert(i+1, back)
|
document.body.insert(i+1, back)
|
||||||
# We cannot use SpecialChar since we do not know whether we are outside passThru
|
# We cannot use SpecialChar since we do not know whether we are outside passThru
|
||||||
document.body[i] = front + "\\SpecialCharNoPassThru \\" + phrase
|
document.body[i] = front + "\\SpecialCharNoPassThru \\" + phrase
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
|
||||||
def revert_phrases(document):
|
def revert_phrases(document):
|
||||||
|
Loading…
Reference in New Issue
Block a user