summaryrefslogtreecommitdiff
path: root/i18npool
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 /i18npool
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 'i18npool')
-rw-r--r--i18npool/source/breakiterator/breakiterator_ctl.cxx4
-rw-r--r--i18npool/source/breakiterator/xdictionary.cxx2
-rw-r--r--i18npool/source/search/levdis.cxx10
-rw-r--r--i18npool/source/search/textsearch.cxx4
-rw-r--r--i18npool/source/transliteration/textToPronounce_zh.cxx2
-rw-r--r--i18npool/source/transliteration/transliteration_Ignore.cxx4
6 files changed, 12 insertions, 14 deletions
diff --git a/i18npool/source/breakiterator/breakiterator_ctl.cxx b/i18npool/source/breakiterator/breakiterator_ctl.cxx
index 4f4410e2f369..b307c37fd9ac 100644
--- a/i18npool/source/breakiterator/breakiterator_ctl.cxx
+++ b/i18npool/source/breakiterator/breakiterator_ctl.cxx
@@ -71,7 +71,7 @@ sal_Int32 SAL_CALL BreakIterator_CTL::previousCharacters( const OUString& Text,
} else
nStartPos = 0;
} else { // for BS to delete one char.
- nDone = (nStartPos > nCount) ? nCount : nStartPos;
+ nDone = std::min(nStartPos, nCount);
nStartPos -= nDone;
}
@@ -98,7 +98,7 @@ sal_Int32 SAL_CALL BreakIterator_CTL::nextCharacters(const OUString& Text,
} else
nStartPos = len;
} else {
- nDone = (len - nStartPos > nCount) ? nCount : len - nStartPos;
+ nDone = std::min(len - nStartPos, nCount);
nStartPos += nDone;
}
diff --git a/i18npool/source/breakiterator/xdictionary.cxx b/i18npool/source/breakiterator/xdictionary.cxx
index 5826b5cca6a8..b177b07973a4 100644
--- a/i18npool/source/breakiterator/xdictionary.cxx
+++ b/i18npool/source/breakiterator/xdictionary.cxx
@@ -459,7 +459,7 @@ Boundary const & xdictionary::getWordBoundary(const OUString& rText, sal_Int32 a
} else {
boundary.startPos = anyPos;
if (anyPos < len) rText.iterateCodePoints(&anyPos);
- boundary.endPos = anyPos < len ? anyPos : len;
+ boundary.endPos = std::min(anyPos, len);
}
if (wordType == WordType::WORD_COUNT) {
// skip punctuation for word count.
diff --git a/i18npool/source/search/levdis.cxx b/i18npool/source/search/levdis.cxx
index 7795cf7bc168..9e4d9afe527c 100644
--- a/i18npool/source/search/levdis.cxx
+++ b/i18npool/source/search/levdis.cxx
@@ -316,9 +316,9 @@ int WLevDistance::LCM( int a, int b )
inline int WLevDistance::Min3( int x, int y, int z )
{
if ( x < y )
- return( x < z ? x : z );
+ return std::min(x, z);
else
- return( y < z ? y : z );
+ return std::min(y, z);
}
// The value in the middle
@@ -326,11 +326,11 @@ int WLevDistance::Mid3( int x, int y, int z )
{
int min = Min3(x,y,z);
if ( x == min )
- return( y < z ? y : z);
+ return std::min(y, z);
else if ( y == min )
- return( x < z ? x : z);
+ return std::min(x, z);
else // z == min
- return( x < y ? x : y);
+ return std::min(x, y);
}
// Maximum of three values
diff --git a/i18npool/source/search/textsearch.cxx b/i18npool/source/search/textsearch.cxx
index 6f51d3b2cbf0..a2c20342bee3 100644
--- a/i18npool/source/search/textsearch.cxx
+++ b/i18npool/source/search/textsearch.cxx
@@ -1062,7 +1062,7 @@ SearchResult TextSearch::ApproxSrchFrwrd( const OUString& searchStr,
if( aWBnd.startPos >= endPos )
break;
nStt = aWBnd.startPos < startPos ? startPos : aWBnd.startPos;
- nEnd = aWBnd.endPos > endPos ? endPos : aWBnd.endPos;
+ nEnd = std::min(aWBnd.endPos, endPos);
if( nStt < nEnd &&
pWLD->WLD( searchStr.getStr() + nStt, nEnd - nStt ) <= nLimit )
@@ -1106,7 +1106,7 @@ SearchResult TextSearch::ApproxSrchBkwrd( const OUString& searchStr,
if( aWBnd.endPos <= endPos )
break;
nStt = aWBnd.startPos < endPos ? endPos : aWBnd.startPos;
- nEnd = aWBnd.endPos > startPos ? startPos : aWBnd.endPos;
+ nEnd = std::min(aWBnd.endPos, startPos);
if( nStt < nEnd &&
pWLD->WLD( searchStr.getStr() + nStt, nEnd - nStt ) <= nLimit )
diff --git a/i18npool/source/transliteration/textToPronounce_zh.cxx b/i18npool/source/transliteration/textToPronounce_zh.cxx
index 6baf434f5e7e..d9ca2ece5dd2 100644
--- a/i18npool/source/transliteration/textToPronounce_zh.cxx
+++ b/i18npool/source/transliteration/textToPronounce_zh.cxx
@@ -103,7 +103,7 @@ TextToPronounce_zh::equals( const OUString & str1, sal_Int32 pos1, sal_Int32 nCo
if (nCount2 + pos2 > str2.getLength())
nCount2 = str2.getLength() - pos2;
- realCount = ((nCount1 > nCount2) ? nCount2 : nCount1);
+ realCount = std::min(nCount1, nCount2);
s1 = str1.getStr() + pos1;
s2 = str2.getStr() + pos2;
diff --git a/i18npool/source/transliteration/transliteration_Ignore.cxx b/i18npool/source/transliteration/transliteration_Ignore.cxx
index 503bf7d1858e..3a256fd34ae0 100644
--- a/i18npool/source/transliteration/transliteration_Ignore.cxx
+++ b/i18npool/source/transliteration/transliteration_Ignore.cxx
@@ -24,8 +24,6 @@ using namespace com::sun::star::uno;
namespace i18npool {
-inline sal_Int32 Min( sal_Int32 a, sal_Int32 b ) { return a > b ? b : a; }
-
sal_Bool SAL_CALL
transliteration_Ignore::equals(const OUString& str1, sal_Int32 pos1, sal_Int32 nCount1, sal_Int32& nMatch1,
const OUString& str2, sal_Int32 pos2, sal_Int32 nCount2, sal_Int32& nMatch2 )
@@ -39,7 +37,7 @@ transliteration_Ignore::equals(const OUString& str1, sal_Int32 pos1, sal_Int32 n
const sal_Unicode * p1 = s1.getStr();
const sal_Unicode * p2 = s2.getStr();
- sal_Int32 length = Min(s1.getLength(), s2.getLength());
+ sal_Int32 length = std::min(s1.getLength(), s2.getLength());
sal_Int32 nmatch;
for ( nmatch = 0; nmatch < length; nmatch++)