]> git.lyx.org Git - features.git/commitdiff
Paragraph::needsCProtection(): use inset list
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 19 Dec 2021 14:39:49 +0000 (15:39 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 19 Dec 2021 14:39:49 +0000 (15:39 +0100)
rather than checking each pos whether it's an inset or not.

This was a significant performance bottleneck (particularly getInset()
itself seems slow).

src/Paragraph.cpp

index 7fb46aee7daa1a474ff529596d652698e06bf81f..2408261665ecf92f4fe9438250de2482c98d9176 100644 (file)
@@ -4108,15 +4108,14 @@ bool Paragraph::needsCProtection(bool const fragile) const
        }
 
        // now check whether we have insets that need cprotection
-       pos_type size = pos_type(d->text_.size());
-       for (pos_type i = 0; i < size; ++i) {
-               if (!isInset(i))
+       for (auto const & icit : d->insetlist_) {
+               Inset const * ins = icit.inset;
+               if (!ins)
                        continue;
-               Inset const * ins = getInset(i);
                if (ins->needsCProtection(maintext, fragile))
                        return true;
                // Now check math environments
-               InsetMath const * im = getInset(i)->asInsetMath();
+               InsetMath const * im = ins->asInsetMath();
                if (!im || im->cell(0).empty())
                        continue;
                switch(im->cell(0)[0]->lyxCode()) {