mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Pass DocumentClassConstPtr arguments by const reference
This arguments are shared_ptr objects, so they are not expensive to copy. However, it makes sense to pass such pointers by const reference when they are just intended for reading. Some reading about this issue is here: https://www.internalpointers.com/post/move-smart-pointers-and-out-functions-modern-c Fixes some Coverity scan defects.
This commit is contained in:
parent
3649cea9e5
commit
58ee4c9ec7
@ -2752,7 +2752,7 @@ DocumentClassConstPtr BufferParams::documentClassPtr() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BufferParams::setDocumentClass(DocumentClassConstPtr tc)
|
void BufferParams::setDocumentClass(DocumentClassConstPtr const & tc)
|
||||||
{
|
{
|
||||||
// evil, but this function is evil
|
// evil, but this function is evil
|
||||||
doc_class_ = const_pointer_cast<DocumentClass>(tc);
|
doc_class_ = const_pointer_cast<DocumentClass>(tc);
|
||||||
|
@ -165,7 +165,7 @@ public:
|
|||||||
/// This bypasses the baseClass and sets the textClass directly.
|
/// This bypasses the baseClass and sets the textClass directly.
|
||||||
/// Should be called with care and would be better not being here,
|
/// Should be called with care and would be better not being here,
|
||||||
/// but it seems to be needed by CutAndPaste::putClipboard().
|
/// but it seems to be needed by CutAndPaste::putClipboard().
|
||||||
void setDocumentClass(DocumentClassConstPtr);
|
void setDocumentClass(DocumentClassConstPtr const &);
|
||||||
/// List of modules in use
|
/// List of modules in use
|
||||||
LayoutModuleList const & getModules() const { return layout_modules_; }
|
LayoutModuleList const & getModules() const { return layout_modules_; }
|
||||||
/// List of default modules the user has removed
|
/// List of default modules the user has removed
|
||||||
|
@ -1162,7 +1162,7 @@ void BufferView::makeDocumentClass()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BufferView::updateDocumentClass(DocumentClassConstPtr olddc)
|
void BufferView::updateDocumentClass(DocumentClassConstPtr const & olddc)
|
||||||
{
|
{
|
||||||
StableDocIterator backcur(d->cursor_);
|
StableDocIterator backcur(d->cursor_);
|
||||||
ErrorList & el = buffer_.errorList("Class Switch");
|
ErrorList & el = buffer_.errorList("Class Switch");
|
||||||
|
@ -456,7 +456,7 @@ private:
|
|||||||
void updateHoveredInset() const;
|
void updateHoveredInset() const;
|
||||||
|
|
||||||
///
|
///
|
||||||
void updateDocumentClass(DocumentClassConstPtr olddc);
|
void updateDocumentClass(DocumentClassConstPtr const & olddc);
|
||||||
///
|
///
|
||||||
int width_;
|
int width_;
|
||||||
///
|
///
|
||||||
|
@ -600,7 +600,7 @@ PitPosPair eraseSelectionHelper(BufferParams const & params,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Buffer * copyToTempBuffer(ParagraphList const & paragraphs, DocumentClassConstPtr docclass)
|
Buffer * copyToTempBuffer(ParagraphList const & paragraphs, DocumentClassConstPtr const & docclass)
|
||||||
{
|
{
|
||||||
// This used to need to be static to avoid a memory leak. It no longer needs
|
// This used to need to be static to avoid a memory leak. It no longer needs
|
||||||
// to be so, but the alternative is to construct a new one of these (with a
|
// to be so, but the alternative is to construct a new one of these (with a
|
||||||
@ -828,15 +828,15 @@ bool multipleCellsSelected(CursorData const & cur)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void switchBetweenClasses(DocumentClassConstPtr oldone,
|
void switchBetweenClasses(DocumentClassConstPtr const & oldone,
|
||||||
DocumentClassConstPtr newone, InsetText & in) {
|
DocumentClassConstPtr const & newone, InsetText & in) {
|
||||||
ErrorList el = {};
|
ErrorList el = {};
|
||||||
switchBetweenClasses(oldone, newone, in, el);
|
switchBetweenClasses(oldone, newone, in, el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void switchBetweenClasses(DocumentClassConstPtr oldone,
|
void switchBetweenClasses(DocumentClassConstPtr const & oldone,
|
||||||
DocumentClassConstPtr newone, InsetText & in, ErrorList & errorlist)
|
DocumentClassConstPtr const & newone, InsetText & in, ErrorList & errorlist)
|
||||||
{
|
{
|
||||||
errorlist.clear();
|
errorlist.clear();
|
||||||
|
|
||||||
|
@ -138,11 +138,11 @@ void pasteParagraphList(Cursor & cur, ParagraphList const & parlist,
|
|||||||
* It changes layouts and character styles. Errors are reported
|
* It changes layouts and character styles. Errors are reported
|
||||||
* in the passed ErrorList.
|
* in the passed ErrorList.
|
||||||
*/
|
*/
|
||||||
void switchBetweenClasses(DocumentClassConstPtr oldone,
|
void switchBetweenClasses(DocumentClassConstPtr const & oldone,
|
||||||
DocumentClassConstPtr newone, InsetText & in, ErrorList & el);
|
DocumentClassConstPtr const & newone, InsetText & in, ErrorList & el);
|
||||||
/// Same but without error reporting.
|
/// Same but without error reporting.
|
||||||
void switchBetweenClasses(DocumentClassConstPtr oldone,
|
void switchBetweenClasses(DocumentClassConstPtr const & oldone,
|
||||||
DocumentClassConstPtr newone, InsetText & in);
|
DocumentClassConstPtr const & newone, InsetText & in);
|
||||||
|
|
||||||
/// Get the current selection as a string. Does not change the selection.
|
/// Get the current selection as a string. Does not change the selection.
|
||||||
/// Does only work if the whole selection is in mathed.
|
/// Does only work if the whole selection is in mathed.
|
||||||
|
Loading…
Reference in New Issue
Block a user