summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-01-11 08:47:15 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-01-15 07:26:17 +0100
commit7d8e94444d989d0ac4a4055b207726708e9ec0da (patch)
treece3e4a09ed7932496c4d901360ff23787c8f6e24 /sc
parent80fb8d406ced47e6a2089f0c8ba5c103d2fec91f (diff)
convert a<b?a:b to std::min(a,b)
with something like git grep -nP '(.*)\s*<\s*(.*)\s*\?\s*\g1\s*:\s*\g2' -- *.?xx Change-Id: Id5078b35961847feb78a66204fdb7598ee63fd23 Note: we also convert a>b?b:a Reviewed-on: https://gerrit.libreoffice.org/47736 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/address.hxx6
-rw-r--r--sc/source/core/data/dpfilteredcache.cxx2
-rw-r--r--sc/source/core/data/table6.cxx4
-rw-r--r--sc/source/core/opencl/op_spreadsheet.cxx2
-rw-r--r--sc/source/core/tool/compiler.cxx2
-rw-r--r--sc/source/core/tool/dbdata.cxx2
-rw-r--r--sc/source/core/tool/interpr3.cxx2
-rw-r--r--sc/source/core/tool/reftokenhelper.cxx2
-rw-r--r--sc/source/core/tool/scmatrix.cxx2
-rw-r--r--sc/source/filter/lotus/lotimpop.cxx2
-rw-r--r--sc/source/filter/lotus/op.cxx10
-rw-r--r--sc/source/filter/qpro/qpro.cxx2
-rw-r--r--sc/source/filter/xml/xmlcelli.cxx8
-rw-r--r--sc/source/ui/view/tabview2.cxx4
14 files changed, 25 insertions, 25 deletions
diff --git a/sc/inc/address.hxx b/sc/inc/address.hxx
index 0c4610d98474..2be0ff1ccb7b 100644
--- a/sc/inc/address.hxx
+++ b/sc/inc/address.hxx
@@ -121,17 +121,17 @@ SAL_WARN_UNUSED_RESULT inline bool ValidColRowTab( SCCOL nCol, SCROW nRow, SCTAB
SAL_WARN_UNUSED_RESULT inline SCCOL SanitizeCol( SCCOL nCol )
{
- return nCol < 0 ? 0 : (nCol > MAXCOL ? MAXCOL : nCol);
+ return nCol < 0 ? 0 : std::min(nCol, MAXCOL);
}
SAL_WARN_UNUSED_RESULT inline SCROW SanitizeRow( SCROW nRow )
{
- return nRow < 0 ? 0 : (nRow > MAXROW ? MAXROW : nRow);
+ return nRow < 0 ? 0 : std::min(nRow, MAXROW);
}
SAL_WARN_UNUSED_RESULT inline SCTAB SanitizeTab( SCTAB nTab )
{
- return nTab < 0 ? 0 : (nTab > MAXTAB ? MAXTAB : nTab);
+ return nTab < 0 ? 0 : std::min(nTab, MAXTAB);
}
// The result of ConvertRef() is a bit group of the following:
diff --git a/sc/source/core/data/dpfilteredcache.cxx b/sc/source/core/data/dpfilteredcache.cxx
index 3b53741064fb..de5c139b30de 100644
--- a/sc/source/core/data/dpfilteredcache.cxx
+++ b/sc/source/core/data/dpfilteredcache.cxx
@@ -235,7 +235,7 @@ bool ScDPFilteredCache::isRowActive(sal_Int32 nRow, sal_Int32* pLastRow) const
if (pLastRow)
{
// Return the last row of current segment.
- *pLastRow = nLastRowFilter < nLastRowPage ? nLastRowFilter : nLastRowPage;
+ *pLastRow = std::min(nLastRowFilter, nLastRowPage);
*pLastRow -= 1; // End position is not inclusive. Move back one.
}
diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx
index af36752dc05a..4e0666846cb0 100644
--- a/sc/source/core/data/table6.cxx
+++ b/sc/source/core/data/table6.cxx
@@ -949,7 +949,7 @@ bool ScTable::SearchRangeForEmptyCell(
{
// row direction.
SCROW nLastNonFilteredRow = MAXROW + 1;
- SCROW nBeginRow = rRange.aEnd.Row() > rRow ? rRow : rRange.aEnd.Row();
+ SCROW nBeginRow = std::min(rRange.aEnd.Row(), rRow);
for (SCROW nRow = nBeginRow; nRow >= rRange.aStart.Row(); --nRow)
{
if (bSkipFiltered)
@@ -972,7 +972,7 @@ bool ScTable::SearchRangeForEmptyCell(
else
{
// column direction.
- SCCOL nBeginCol = rRange.aEnd.Col() > rCol ? rCol : rRange.aEnd.Col();
+ SCCOL nBeginCol = std::min(rRange.aEnd.Col(), rCol);
for (SCCOL nCol = nBeginCol; nCol >= rRange.aStart.Col(); --nCol)
{
SCROW nLastNonFilteredRow = MAXROW + 1;
diff --git a/sc/source/core/opencl/op_spreadsheet.cxx b/sc/source/core/opencl/op_spreadsheet.cxx
index 301deeeabc9a..be5fc318bce6 100644
--- a/sc/source/core/opencl/op_spreadsheet.cxx
+++ b/sc/source/core/opencl/op_spreadsheet.cxx
@@ -98,7 +98,7 @@ void OpVLookup::GenSlidingWindowFunction(std::stringstream &ss,
{
tmpCur = vSubArguments[1]->GetFormulaToken();
pCurDVR = static_cast<const formula::DoubleVectorRefToken *>(tmpCur);
- size_t nCurWindowSize = pCurDVR->GetArrayLength() < pCurDVR->GetRefRowSize() ? pCurDVR->GetArrayLength() : pCurDVR->GetRefRowSize() ;
+ size_t nCurWindowSize = std::min(pCurDVR->GetArrayLength(), pCurDVR->GetRefRowSize());
int unrollSize = 8;
ss << " int loop;\n";
if (!pCurDVR->IsStartFixed() && pCurDVR->IsEndFixed())
diff --git a/sc/source/core/tool/compiler.cxx b/sc/source/core/tool/compiler.cxx
index a7b7b8d9629b..ba03e59ff95a 100644
--- a/sc/source/core/tool/compiler.cxx
+++ b/sc/source/core/tool/compiler.cxx
@@ -4111,7 +4111,7 @@ bool ScCompiler::NextNewToken( bool bInArray )
{
ScRawToken aToken;
aToken.SetOpCode( ocSpaces );
- aToken.sbyte.cByte = static_cast<sal_uInt8>( nSpaces > 255 ? 255 : nSpaces );
+ aToken.sbyte.cByte = static_cast<sal_uInt8>( std::min<sal_Int32>(nSpaces, 255) );
if( !static_cast<ScTokenArray*>(pArr)->AddRawToken( aToken ) )
{
SetError(FormulaError::CodeOverflow);
diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index 633af20860b9..efb3f15671cf 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -678,7 +678,7 @@ void ScDBData::AdjustTableColumnNames( UpdateRefMode eUpdateRefMode, SCCOL nDx,
// nCol1 is the first column of the block that gets shifted, determine
// the head and tail elements that are to be copied for deletion or
// insertion.
- size_t nHead = static_cast<size_t>(::std::max( nCol1 + (nDx < 0 ? nDx : 0) - nOldCol1, 0));
+ size_t nHead = static_cast<size_t>(::std::max( nCol1 + std::min<SCCOL>(nDx, 0) - nOldCol1, 0));
size_t nTail = static_cast<size_t>(::std::max( nOldCol2 - nCol1 + 1, 0));
size_t n = nHead + nTail;
if (0 < n && n <= maTableColumnNames.size())
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 723c75d8139f..55b80a6612e9 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -1261,7 +1261,7 @@ double lcl_GetBinomDistRange(double n, double xs,double xe,
fFactor *= (n-i+1)/i * p/q;
fSum += fFactor;
}
- return (fSum>1.0) ? 1.0 : fSum;
+ return std::min(fSum,1.0);
}
void ScInterpreter::ScB()
diff --git a/sc/source/core/tool/reftokenhelper.cxx b/sc/source/core/tool/reftokenhelper.cxx
index 1d792f7222c8..d1422f1ab266 100644
--- a/sc/source/core/tool/reftokenhelper.cxx
+++ b/sc/source/core/tool/reftokenhelper.cxx
@@ -300,7 +300,7 @@ private:
// These two ranges cannot be joined. Move on.
return false;
- T nMin = nMin1 < nMin2 ? nMin1 : nMin2;
+ T nMin = std::min(nMin1, nMin2);
T nMax = std::max(nMax1, nMax2);
rNewMin = nMin;
diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx
index 19d4b62394b6..d22fdd347e26 100644
--- a/sc/source/core/tool/scmatrix.cxx
+++ b/sc/source/core/tool/scmatrix.cxx
@@ -363,7 +363,7 @@ static size_t GetElementsMax( size_t nMemory )
// With MAXROWCOUNT==1048576 and 128 columns => 128M elements, 1.5GB
constexpr size_t nArbitraryLimit = size_t(MAXROWCOUNT) * 128;
// With the constant 1GB from above that's the actual value.
- return nElemMax < nArbitraryLimit ? nElemMax : nArbitraryLimit;
+ return std::min(nElemMax, nArbitraryLimit);
}
ScMatrixImpl::ScMatrixImpl(SCSIZE nC, SCSIZE nR) :
diff --git a/sc/source/filter/lotus/lotimpop.cxx b/sc/source/filter/lotus/lotimpop.cxx
index 4ee58da7d29c..51367b9d08e5 100644
--- a/sc/source/filter/lotus/lotimpop.cxx
+++ b/sc/source/filter/lotus/lotimpop.cxx
@@ -267,7 +267,7 @@ void ImportLotus::Formulacell( sal_uInt16 n )
Read( aAddr );
Skip( 10 );
- n -= (n > 14) ? 14 : n;
+ n -= std::min<sal_uInt16>(n, 14);
const ScTokenArray* pErg;
sal_Int32 nRest = n;
diff --git a/sc/source/filter/lotus/op.cxx b/sc/source/filter/lotus/op.cxx
index ffd47264a316..3998a08ca088 100644
--- a/sc/source/filter/lotus/op.cxx
+++ b/sc/source/filter/lotus/op.cxx
@@ -114,7 +114,7 @@ void OP_Label(LotusContext& rContext, SvStream& r, sal_uInt16 n)
SCCOL nCol(static_cast<SCCOL>(nTmpCol));
SCROW nRow(static_cast<SCROW>(nTmpRow));
- n -= (n > 5) ? 5 : n;
+ n -= std::min<sal_uInt16>(n, 5);
std::unique_ptr<sal_Char[]> pText(new sal_Char[n + 1]);
r.ReadBytes(pText.get(), n);
@@ -356,7 +356,7 @@ void OP_Label123(LotusContext& rContext, SvStream& r, sal_uInt16 n)
SCCOL nCol(static_cast<SCCOL>(nTmpCol));
SCROW nRow(static_cast<SCROW>(nTmpRow));
- n -= (n > 4) ? 4 : n;
+ n -= std::min<sal_uInt16>(n, 4);
std::unique_ptr<sal_Char[]> pText(new sal_Char[n + 1]);
r.ReadBytes(pText.get(), n);
@@ -439,7 +439,7 @@ void OP_Note123(LotusContext& rContext, SvStream& r, sal_uInt16 n)
SCCOL nCol(static_cast<SCCOL>(nTmpCol));
SCROW nRow(static_cast<SCROW>(nTmpRow));
- n -= (n > 4) ? 4 : n;
+ n -= std::min<sal_uInt16>(n, 4);
std::unique_ptr<sal_Char[]> pText(new sal_Char[n + 1]);
r.ReadBytes(pText.get(), n);
@@ -522,7 +522,7 @@ void OP_CreatePattern123(LotusContext& rContext, SvStream& r, sal_uInt16 n)
SfxItemSet& rItemSet = aPattern.GetItemSet();
r.ReadUInt16( nCode );
- n -= (n > 2) ? 2 : n;
+ n -= std::min<sal_uInt16>(n, 2);
if ( nCode == 0x0fd2 )
{
@@ -557,7 +557,7 @@ void OP_CreatePattern123(LotusContext& rContext, SvStream& r, sal_uInt16 n)
OP_VerAlign123(rContext, Ver_Align, rItemSet );
rContext.aLotusPatternPool.emplace( nPatternId, aPattern );
- n -= (n > 20) ? 20 : n;
+ n -= std::min<sal_uInt16>(n, 20);
}
r.SeekRel(n);
}
diff --git a/sc/source/filter/qpro/qpro.cxx b/sc/source/filter/qpro/qpro.cxx
index 0c1d18d59ffd..13bb055e1c3a 100644
--- a/sc/source/filter/qpro/qpro.cxx
+++ b/sc/source/filter/qpro/qpro.cxx
@@ -251,7 +251,7 @@ bool ScQProReader::nextRecord()
#if 1 // rather verbose
int len = mnLength;
while (len > 0) {
- int i, chunk = len < 16 ? len : 16;
+ int i, chunk = std::min(len, 16);
unsigned char data[16];
mpStream->Read( data, chunk );
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index 0148dc965026..4d393f9f1e61 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1341,10 +1341,10 @@ void ScXMLTableRowCellContext::AddNonFormulaCell( const ScAddress& rCellPos )
if( CellsAreRepeated() )
{
- SCCOL nStartCol( rCellPos.Col() < MAXCOL ? rCellPos.Col() : MAXCOL );
- SCROW nStartRow( rCellPos.Row() < MAXROW ? rCellPos.Row() : MAXROW );
- SCCOL nEndCol( rCellPos.Col() + nColsRepeated - 1 < MAXCOL ? rCellPos.Col() + nColsRepeated - 1 : MAXCOL );
- SCROW nEndRow( rCellPos.Row() + nRepeatedRows - 1 < MAXROW ? rCellPos.Row() + nRepeatedRows - 1 : MAXROW );
+ SCCOL nStartCol( std::min(rCellPos.Col(), MAXCOL) );
+ SCROW nStartRow( std::min(rCellPos.Row(), MAXROW) );
+ SCCOL nEndCol( std::min<SCCOL>(rCellPos.Col() + nColsRepeated - 1, MAXCOL) );
+ SCROW nEndRow( std::min(rCellPos.Row() + nRepeatedRows - 1, MAXROW) );
ScRange aScRange( nStartCol, nStartRow, rCellPos.Tab(), nEndCol, nEndRow, rCellPos.Tab() );
SetContentValidation( aScRange );
rXMLImport.GetStylesImportHelper()->AddRange( aScRange );
diff --git a/sc/source/ui/view/tabview2.cxx b/sc/source/ui/view/tabview2.cxx
index cf4770798a19..da36ab8dff66 100644
--- a/sc/source/ui/view/tabview2.cxx
+++ b/sc/source/ui/view/tabview2.cxx
@@ -578,8 +578,8 @@ void ScTabView::MarkCursor( SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
nBlockStartX = nBlockStartX + nBlockStartXOffset >= 0 ? nBlockStartX + nBlockStartXOffset : 0;
nBlockStartY = nBlockStartY + nBlockStartYOffset >= 0 ? nBlockStartY + nBlockStartYOffset : 0;
- nBlockEndX = nCurX + nCurXOffset > MAXCOL ? MAXCOL : nCurX + nCurXOffset;
- nBlockEndY = nCurY + nCurYOffset > MAXROW ? MAXROW : nCurY + nCurYOffset;
+ nBlockEndX = std::min<SCCOL>(nCurX + nCurXOffset, MAXCOL);
+ nBlockEndY = std::min(nCurY + nCurYOffset, MAXROW);
}
else
{