commit 8e0db14344f6b4cf0cd8b6bb2923ae289041f7d6 Author: Jean-Marc Lasgouttes <lasgout...@lyx.org> Date: Sun Feb 16 18:55:29 2025 +0100
Use emplace_back() to avoid copying TocItem objects (spotted by Coverity Scan) --- src/insets/InsetLabel.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index b4b885ad9d..bfb12e462a 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -226,22 +226,21 @@ void InsetLabel::addToToc(DocIterator const & cpit, bool output_active, // We put both active and inactive labels to the outliner shared_ptr<Toc> toc = backend.toc("label"); - TocItem toc_item = TocItem(cpit, 0, screen_label_, output_active); - toc_item.prettyStr(formatted_counter_); - toc->push_back(toc_item); + toc->emplace_back(cpit, 0, screen_label_, output_active); + toc->back().prettyStr(formatted_counter_); // The refs get assigned only to the active label. If no active one exists, // assign the (BROKEN) refs to the first inactive one. if (buffer().insetLabel(label, true) == this || !buffer().activeLabel(label)) { for (auto const & p : buffer().references(label)) { DocIterator const ref_pit(p.second); if (p.first->lyxCode() == MATH_REF_CODE) - toc->push_back(TocItem(ref_pit, 1, + toc->emplace_back(ref_pit, 1, p.first->asInsetMath()->asRefInset()->screenLabel(), - output_active)); + output_active); else - toc->push_back(TocItem(ref_pit, 1, + toc->emplace_back(ref_pit, 1, static_cast<InsetRef *>(p.first)->getTOCString(), - static_cast<InsetRef *>(p.first)->outputActive())); + static_cast<InsetRef *>(p.first)->outputActive()); } } } -- lyx-cvs mailing list lyx-cvs@lists.lyx.org https://lists.lyx.org/mailman/listinfo/lyx-cvs