mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Pass shared_ptr<> arguments by const reference
These arguments 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
58ee4c9ec7
commit
3af0bad22a
@ -24,7 +24,7 @@ namespace lyx {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
TocBuilder::TocBuilder(shared_ptr<Toc> toc)
|
TocBuilder::TocBuilder(shared_ptr<Toc> const & toc)
|
||||||
: toc_(toc ? toc : make_shared<Toc>()),
|
: toc_(toc ? toc : make_shared<Toc>()),
|
||||||
stack_()
|
stack_()
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ class DocIterator;
|
|||||||
class TocBuilder
|
class TocBuilder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TocBuilder(std::shared_ptr<Toc> toc);
|
TocBuilder(std::shared_ptr<Toc> const & toc);
|
||||||
/// Open a level.
|
/// Open a level.
|
||||||
/// When entering a float or flex or paragraph (with AddToToc)
|
/// When entering a float or flex or paragraph (with AddToToc)
|
||||||
void pushItem(DocIterator const & dit, docstring const & s,
|
void pushItem(DocIterator const & dit, docstring const & s,
|
||||||
|
@ -40,7 +40,7 @@ Action::Action(FuncRequest func, QIcon const & icon, QString const & text,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Action::Action(shared_ptr<FuncRequest const> func,
|
Action::Action(shared_ptr<FuncRequest const> const & func,
|
||||||
QIcon const & icon, QString const & text,
|
QIcon const & icon, QString const & text,
|
||||||
QString const & tooltip, QObject * parent)
|
QString const & tooltip, QObject * parent)
|
||||||
: QAction(parent), func_(func), icon_(icon)
|
: QAction(parent), func_(func), icon_(icon)
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
|
|
||||||
// Takes shared ownership of func.
|
// Takes shared ownership of func.
|
||||||
// Use for perf-sensitive code such as populating menus.
|
// Use for perf-sensitive code such as populating menus.
|
||||||
Action(std::shared_ptr<FuncRequest const> func,
|
Action(std::shared_ptr<FuncRequest const> const & func,
|
||||||
QIcon const & icon, QString const & text,
|
QIcon const & icon, QString const & text,
|
||||||
QString const & tooltip, QObject * parent);
|
QString const & tooltip, QObject * parent);
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ void TocModel::updateItem(DocIterator const & dit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TocModel::reset(shared_ptr<Toc const> toc)
|
void TocModel::reset(shared_ptr<Toc const> const & toc)
|
||||||
{
|
{
|
||||||
toc_ = toc;
|
toc_ = toc;
|
||||||
if (toc_->empty()) {
|
if (toc_->empty()) {
|
||||||
|
@ -39,7 +39,7 @@ public:
|
|||||||
///
|
///
|
||||||
TocModel(QObject * parent);
|
TocModel(QObject * parent);
|
||||||
///
|
///
|
||||||
void reset(std::shared_ptr<Toc const>);
|
void reset(std::shared_ptr<Toc const> const &);
|
||||||
///
|
///
|
||||||
void reset();
|
void reset();
|
||||||
///
|
///
|
||||||
|
@ -158,7 +158,7 @@ void FileMonitorGuard::notifyChange(QString const & path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FileMonitor::FileMonitor(std::shared_ptr<FileMonitorGuard> monitor)
|
FileMonitor::FileMonitor(std::shared_ptr<FileMonitorGuard> const & monitor)
|
||||||
: monitor_(monitor)
|
: monitor_(monitor)
|
||||||
{
|
{
|
||||||
connectToFileMonitorGuard();
|
connectToFileMonitorGuard();
|
||||||
@ -193,7 +193,7 @@ void FileMonitor::changed(bool const exists)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ActiveFileMonitor::ActiveFileMonitor(std::shared_ptr<FileMonitorGuard> monitor,
|
ActiveFileMonitor::ActiveFileMonitor(std::shared_ptr<FileMonitorGuard> const & monitor,
|
||||||
FileName const & filename, int interval)
|
FileName const & filename, int interval)
|
||||||
: FileMonitor(monitor), filename_(filename), interval_(interval),
|
: FileMonitor(monitor), filename_(filename), interval_(interval),
|
||||||
timestamp_(0), checksum_(0), cooldown_(true)
|
timestamp_(0), checksum_(0), cooldown_(true)
|
||||||
|
@ -128,7 +128,7 @@ class FileMonitor : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FileMonitor(std::shared_ptr<FileMonitorGuard> monitor);
|
FileMonitor(std::shared_ptr<FileMonitorGuard> const & monitor);
|
||||||
|
|
||||||
typedef signal<void(bool)> sig;
|
typedef signal<void(bool)> sig;
|
||||||
typedef sig::slot_type slot;
|
typedef sig::slot_type slot;
|
||||||
@ -166,7 +166,7 @@ class ActiveFileMonitor : public FileMonitor
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ActiveFileMonitor(std::shared_ptr<FileMonitorGuard> monitor,
|
ActiveFileMonitor(std::shared_ptr<FileMonitorGuard> const & monitor,
|
||||||
FileName const & filename, int interval);
|
FileName const & filename, int interval);
|
||||||
/// call checkModified asynchronously
|
/// call checkModified asynchronously
|
||||||
void checkModifiedAsync();
|
void checkModifiedAsync();
|
||||||
|
Loading…
Reference in New Issue
Block a user