]> git.lyx.org Git - lyx.git/commitdiff
Speed up convert_captionlayouts. Part of #11200.
authorRichard Kimberly Heck <rikiheck@lyx.org>
Tue, 17 Jul 2018 02:14:36 +0000 (22:14 -0400)
committerRichard Kimberly Heck <rikiheck@lyx.org>
Tue, 11 Dec 2018 23:01:29 +0000 (18:01 -0500)
(cherry picked from commit 4cb209b121430b38606932e31d2659bd7ed57447)

lib/lyx2lyx/lyx_2_1.py

index 6e7d8266baf8bf14ee9caba4e558500cf03cd295..b507151cb56eddc00bc01e9a157a8a0d5c2a2fc0 100644 (file)
@@ -3656,23 +3656,22 @@ def convert_captionlayouts(document):
         "Bicaption" : "Bicaption",
         }
 
-    i = 0
-    while True:
-        i = find_token(document.body, "\\begin_layout", i)
-        if i == -1:
-            return
-        val = get_value(document.body, "\\begin_layout", i)
-        if val in list(caption_dict.keys()):
+    for captype in caption_dict.keys():
+        i = 0
+        while True:
+            i = find_token(document.body, "\\begin_layout " + captype, i)
+            if i == -1:
+                break
             j = find_end_of_layout(document.body, i)
             if j == -1:
                 document.warning("Malformed LyX document: Missing `\\end_layout'.")
-                return
+                break
 
             document.body[j:j] = ["\\end_layout", "", "\\end_inset", "", ""]
             document.body[i:i+1] = ["\\begin_layout %s" % document.default_layout,
                                     "\\begin_inset Caption %s" % caption_dict[captype], "",
                                     "\\begin_layout %s" % document.default_layout]
-        i += 1
+            i = j + 1
 
 
 def revert_captionlayouts(document):