Skip to content

Commit 11eb79e

Browse files
kazutakahirataaokblast
authored andcommitted
[ADT, Support] Use std::min and std::max (NFC) (llvm#164145)
1 parent 9736fbe commit 11eb79e

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

llvm/include/llvm/ADT/PagedVector.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ template <typename T, size_t PageSize = 1024 / sizeof(T)> class PagedVector {
189189
while (ElementIdx < PV->Size &&
190190
!PV->PageToDataPtrs[ElementIdx / PageSize])
191191
ElementIdx += PageSize;
192-
if (ElementIdx > PV->Size)
193-
ElementIdx = PV->Size;
192+
ElementIdx = std::min(ElementIdx, PV->Size);
194193
}
195194

196195
return *this;

llvm/include/llvm/Support/GraphWriter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ template <typename GraphType, typename Derived> class GraphWriterBase {
343343
const void *DestNodeID, int DestNodePort,
344344
const std::string &Attrs) {
345345
if (SrcNodePort > 64) return; // Eminating from truncated part?
346-
if (DestNodePort > 64) DestNodePort = 64; // Targeting the truncated part?
346+
DestNodePort = std::min(DestNodePort, 64); // Targeting the truncated part?
347347

348348
O << "\tNode" << SrcNodeID;
349349
if (SrcNodePort >= 0)

llvm/lib/Support/APFloat.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,8 +2600,7 @@ APFloat::opStatus IEEEFloat::convert(const fltSemantics &toSemantics,
26002600
int exponentChange = omsb - fromSemantics.precision;
26012601
if (exponent + exponentChange < toSemantics.minExponent)
26022602
exponentChange = toSemantics.minExponent - exponent;
2603-
if (exponentChange < shift)
2604-
exponentChange = shift;
2603+
exponentChange = std::max(exponentChange, shift);
26052604
if (exponentChange < 0) {
26062605
shift -= exponentChange;
26072606
exponent += exponentChange;
@@ -3043,8 +3042,7 @@ IEEEFloat::roundSignificandWithExponent(const integerPart *decSigParts,
30433042
if (decSig.exponent < semantics->minExponent) {
30443043
excessPrecision += (semantics->minExponent - decSig.exponent);
30453044
truncatedBits = excessPrecision;
3046-
if (excessPrecision > calcSemantics.precision)
3047-
excessPrecision = calcSemantics.precision;
3045+
excessPrecision = std::min(excessPrecision, calcSemantics.precision);
30483046
}
30493047
/* Extra half-ulp lost in reciprocal of exponent. */
30503048
powHUerr = (powStatus == opOK && calcLostFraction == lfExactlyZero) ? 0:2;
@@ -3441,8 +3439,7 @@ char *IEEEFloat::convertNormalToHexString(char *dst, unsigned int hexDigits,
34413439
/* Convert as much of "part" to hexdigits as we can. */
34423440
unsigned int curDigits = integerPartWidth / 4;
34433441

3444-
if (curDigits > outputDigits)
3445-
curDigits = outputDigits;
3442+
curDigits = std::min(curDigits, outputDigits);
34463443
dst += partAsHex (dst, part, curDigits, hexDigitChars);
34473444
outputDigits -= curDigits;
34483445
}

llvm/lib/Support/Unix/Signals.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -868,8 +868,7 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) {
868868
nwidth = strlen(name) - 1;
869869
}
870870

871-
if (nwidth > width)
872-
width = nwidth;
871+
width = std::max(nwidth, width);
873872
}
874873

875874
for (int i = 0; i < depth; ++i) {

0 commit comments

Comments
 (0)