]> git.lyx.org Git - features.git/commitdiff
Speed up convert_literalparam. Part of #11200.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Sun, 22 Jul 2018 02:49:49 +0000 (22:49 -0400)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Tue, 11 Dec 2018 23:03:44 +0000 (18:03 -0500)
(cherry picked from commit 4549f46a431021d6667451ab83965eca12d58f58)

lib/lyx2lyx/lyx_2_3.py
status.23x

index 9a395687df7d1255f5e82770fb65ab2d7733df0d..d6b31708e51d9a9985b6323505263c19401f04af 100644 (file)
@@ -1551,24 +1551,29 @@ command_insets = ["bibitem", "citation", "href", "index_print", "nomenclature"]
 def convert_literalparam(document):
     " Add param literal "
 
-    for inset in command_insets:
-        i = 0
-        while True:
-            i = find_token(document.body, '\\begin_inset CommandInset %s' % inset, i)
-            if i == -1:
-                break
-            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))
-                i += 1
-                continue
-            while i < j and document.body[i].strip() != '':
-                i += 1
-            # href is already fully latexified. Here we can switch off literal.
-            if inset == "href":
-                document.body.insert(i, "literal \"false\"")
-            else:
-                document.body.insert(i, "literal \"true\"")
+    pos = len("\\begin_inset CommandInset ")
+    i = 0
+    while True:
+        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))
+            i += 1
+            continue
+        while i < j and document.body[i].strip() != '':
+            i += 1
+        # href is already fully latexified. Here we can switch off literal.
+        if inset == "href":
+            document.body.insert(i, "literal \"false\"")
+        else:
+            document.body.insert(i, "literal \"true\"")
+        i = j + 1
 
 
 
index ba917afaee7956ac60c4f350d235fafb54c94fa2..36335aba2cecb6f41b275043e0abf6016f372d02 100644 (file)
@@ -63,6 +63,11 @@ What's new
 
 
 
+* LYX2LYX
+
+- Speed up some lyx2lyx conversions (bug 11200).
+
+
 * TEX2LYX