Skip to content

Commit

Permalink
tidy: Eliminate unnecessary copying of objects.
Browse files Browse the repository at this point in the history
The clang-tidy "unnecessary value param" check pointed out many places
where objects were passed by copying when they could be passed by
const reference.  The vast majority of these fixes convert a QString
object into a const QString& reference.  There are also a number of
other objects that get passed by reference instead of copying.
Changes made by the clang-tidy program.

https://clang.llvm.org/extra/clang-tidy/checks/performance-unnecessary-value-param.html
  • Loading branch information
linuxdude42 committed Dec 25, 2019
1 parent 1d0a760 commit 5272f22
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion mythtv/libs/libmythui/mythdisplaymode.cpp
Expand Up @@ -120,7 +120,7 @@ bool MythDisplayMode::CompareRates(double First, double Second, double Precision
return qAbs(First - Second) < Precision;
}

int MythDisplayMode::FindBestMatch(const DisplayModeVector Modes,
int MythDisplayMode::FindBestMatch(const DisplayModeVector& Modes,
const MythDisplayMode& Mode, double &TargetRate)
{
double videorate = Mode.RefreshRate();
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythui/mythdisplaymode.h
Expand Up @@ -39,7 +39,7 @@ class MUI_PUBLIC MythDisplayMode
void ClearRefreshRates(void);
void SetRefreshRate(double Rate);
const std::vector<double>& RefreshRates(void) const;
static int FindBestMatch (const DisplayModeVector Modes,
static int FindBestMatch (const DisplayModeVector& Modes,
const MythDisplayMode& Mode, double& TargetRate);
static uint64_t CalcKey (int Width, int Height, double Rate);
static bool CompareRates (double First, double Second, double Precision = 0.01);
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythui/platforms/mythdrmdevice.cpp
Expand Up @@ -14,7 +14,7 @@

#define LOC (QString("%1: ").arg(m_deviceName))

MythDRMDevice::MythDRMDevice(QScreen *qScreen, QString Device)
MythDRMDevice::MythDRMDevice(QScreen *qScreen, const QString& Device)
: ReferenceCounter("DRMDev"),
m_screen(qScreen),
m_deviceName(Device),
Expand Down Expand Up @@ -319,7 +319,7 @@ QString MythDRMDevice::FindBestDevice(void)
return QString();
}

bool MythDRMDevice::ConfirmDevice(QString Device)
bool MythDRMDevice::ConfirmDevice(const QString& Device)
{
bool result = false;
int fd = open(Device.toLocal8Bit().constData(), O_RDWR);
Expand All @@ -335,7 +335,7 @@ bool MythDRMDevice::ConfirmDevice(QString Device)
return result;
}

drmModePropertyBlobPtr MythDRMDevice::GetBlobProperty(drmModeConnectorPtr Connector, QString Property)
drmModePropertyBlobPtr MythDRMDevice::GetBlobProperty(drmModeConnectorPtr Connector, const QString& Property)
{
drmModePropertyBlobPtr result = nullptr;
if (!Connector || Property.isEmpty())
Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythui/platforms/mythdrmdevice.h
Expand Up @@ -18,7 +18,7 @@ extern "C" {
class MythDRMDevice : public ReferenceCounter
{
public:
MythDRMDevice(QScreen *qScreen, QString Device = QString());
MythDRMDevice(QScreen *qScreen, const QString& Device = QString());
~MythDRMDevice() override;

QString GetSerialNumber(void) const;
Expand All @@ -36,9 +36,9 @@ class MythDRMDevice : public ReferenceCounter
bool Initialise (void);

QString FindBestDevice (void);
static bool ConfirmDevice(QString Device);
static bool ConfirmDevice(const QString& Device);

drmModePropertyBlobPtr GetBlobProperty(drmModeConnectorPtr Connector, QString Property);
drmModePropertyBlobPtr GetBlobProperty(drmModeConnectorPtr Connector, const QString& Property);

private:
QScreen* m_screen { nullptr };
Expand Down

0 comments on commit 5272f22

Please sign in to comment.