Skip to content

Commit

Permalink
Remove "using std::min/max" from code.
Browse files Browse the repository at this point in the history
Calling functions from the standard library with std::xxx() makes it
obvious at the point of invocation that its a standard library
function, not a function from some other library. There's no need to
search through all the nested include files to see if somewhere
(possibly 3 or 4 levels deep) there is a "using:xxx" statement.
  • Loading branch information
linuxdude42 committed Dec 29, 2021
1 parent 754b7e6 commit f56767f
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 20 deletions.
6 changes: 2 additions & 4 deletions mythtv/libs/libmyth/audio/audiooutputpulse.cpp
Expand Up @@ -24,7 +24,6 @@

// C++ headers
#include <algorithm>
using std::min;

#define LOC QString("PulseAudio: ")

Expand Down Expand Up @@ -243,7 +242,7 @@ void AudioOutputPulseAudio::WriteAudio(uchar *aubuf, int size)
size_t writable = pa_stream_writable_size(m_pstream);
if (writable > 0)
{
size_t write = min(to_write, writable);
size_t write = std::min(to_write, writable);
write_status = pa_stream_write(m_pstream, buf_ptr, write,
nullptr, 0, PA_SEEK_RELATIVE);

Expand Down Expand Up @@ -334,8 +333,7 @@ void AudioOutputPulseAudio::SetVolumeChannel(int channel, int volume)

// FIXME: This code did nothing at all so has been commented out for now
// until it's decided whether it was ever required
// volume = min(100, volume);
// volume = max(0, volume);
// volume = std::clamp(volume, 0, 100);

if (gCoreContext->GetSetting("MixerControl", "PCM").toLower() == "pcm")
{
Expand Down
1 change: 0 additions & 1 deletion mythtv/libs/libmythmetadata/metadatafactory.cpp
Expand Up @@ -4,7 +4,6 @@
// C++
#include <algorithm>
#include <unistd.h> // for sleep()
using std::max;

// QT
#include <QApplication>
Expand Down
6 changes: 2 additions & 4 deletions mythtv/libs/libmythtv/HLS/httplivestreambuffer.cpp
Expand Up @@ -36,8 +36,6 @@

// C++
#include <algorithm> // for min/max
using std::max;
using std::min;
#include <array>

// libmythbase
Expand Down Expand Up @@ -831,7 +829,7 @@ class HLSStream
// not even size, pad with front 0
line.insert(2, QLatin1String("0"));
}
int padding = max(0, AES_BLOCK_SIZE - (static_cast<int>(line.size()) - 2));
int padding = std::max(0, AES_BLOCK_SIZE - (static_cast<int>(line.size()) - 2));
QByteArray ba = QByteArray(padding, 0x0);
ba.append(QByteArray::fromHex(QByteArray(line.toLatin1().constData() + 2)));
std::copy(ba.cbegin(), ba.cend(), m_aesIv.begin());
Expand Down Expand Up @@ -2576,7 +2574,7 @@ bool HLSRingBuffer::OpenFile(const QString &lfilename, std::chrono::milliseconds
m_streamworker = new StreamWorker(this, m_startup, PLAYBACK_READAHEAD);
m_streamworker->start();

if (Prefetch(min(NumSegments(), PLAYBACK_MINBUFFER)) != RET_OK)
if (Prefetch(std::min(NumSegments(), PLAYBACK_MINBUFFER)) != RET_OK)
{
LOG(VB_PLAYBACK, LOG_ERR, LOC +
"fetching first segment failed or didn't complete within 10s.");
Expand Down
5 changes: 2 additions & 3 deletions mythtv/libs/libmythtv/previewgeneratorqueue.cpp
Expand Up @@ -3,7 +3,6 @@

// C++
#include <algorithm>
using std::max;

// QT
#include <QCoreApplication>
Expand Down Expand Up @@ -222,7 +221,7 @@ void PreviewGeneratorQueue::RemoveListener(QObject *listener)
* generation thread.
* \bug This function appears to incorrectly compute the value of
* lastBlockTime. The call to max() will correctly ensure that if the
* lastBlockTime. The call to std::max() will correctly ensure that if the
* old value of lastBlockTime is zero, that the new time for the first
* "retry" will be two. The problem is that all subsequent "retries"
* will also be limited to two, so there is no increasing back off
Expand Down Expand Up @@ -310,7 +309,7 @@ bool PreviewGeneratorQueue::event(QEvent *e)
else
{
(*it).m_lastBlockTime =
max(m_minBlockSeconds, (*it).m_lastBlockTime * 2);
std::max(m_minBlockSeconds, (*it).m_lastBlockTime * 2);
(*it).m_blockRetryUntil =
MythDate::current().addSecs((*it).m_lastBlockTime.count());
}
Expand Down
5 changes: 2 additions & 3 deletions mythtv/libs/libmythui/mythrender_d3d9.cpp
@@ -1,7 +1,6 @@
#define _WIN32_WINNT 0x500

#include <algorithm>
using std::min;

#include <QLibrary>
#include <QRect>
Expand Down Expand Up @@ -1005,8 +1004,8 @@ bool MythRenderD3D9::UpdateVertexBuffer(IDirect3DVertexBuffer9* vertexbuffer,
int height = dst.height();
if (!video)
{
width = min(src.width(), width);
height = min(src.height(), height);
width = std::min(src.width(), width);
height = std::min(src.height(), height);
}
QRect dest(dst.left(), dst.top(), width, height);

Expand Down
9 changes: 4 additions & 5 deletions mythtv/libs/libmythui/opengl/mythrenderopengl.cpp
@@ -1,7 +1,6 @@
// Std
#include <algorithm>
#include <cmath>
using std::min;

// Qt
#include <QLibrary>
Expand Down Expand Up @@ -1169,8 +1168,8 @@ bool MythRenderOpenGL::UpdateTextureVertices(MythGLTexture *Texture, const QRect
GLfloat *data = Texture->m_vertexData.data();
QSize size = Texture->m_size;

int width = Texture->m_crop ? min(Source.width(), size.width()) : Source.width();
int height = Texture->m_crop ? min(Source.height(), size.height()) : Source.height();
int width = Texture->m_crop ? std::min(Source.width(), size.width()) : Source.width();
int height = Texture->m_crop ? std::min(Source.height(), size.height()) : Source.height();

if (Texture->m_target != QOpenGLTexture::TargetRectangle)
{
Expand All @@ -1192,8 +1191,8 @@ bool MythRenderOpenGL::UpdateTextureVertices(MythGLTexture *Texture, const QRect
data[4 + TEX_OFFSET] = data[6 + TEX_OFFSET];
data[5 + TEX_OFFSET] = data[1 + TEX_OFFSET];

width = Texture->m_crop ? min(static_cast<int>(width * Scale), Destination.width()) : Destination.width();
height = Texture->m_crop ? min(static_cast<int>(height * Scale), Destination.height()) : Destination.height();
width = Texture->m_crop ? std::min(static_cast<int>(width * Scale), Destination.width()) : Destination.width();
height = Texture->m_crop ? std::min(static_cast<int>(height * Scale), Destination.height()) : Destination.height();

data[2] = data[0] = Destination.left();
data[5] = data[1] = Destination.top();
Expand Down

0 comments on commit f56767f

Please sign in to comment.