summaryrefslogtreecommitdiff
path: root/comphelper
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2015-02-26 22:28:31 +0100
committerMichael Stahl <mstahl@redhat.com>2015-02-27 11:25:49 +0100
commit802fe48751e3baaecd9d279ef496c8a2c3cb0a2c (patch)
tree722eb6da7dca18cf63ed755575064438fa7551d2 /comphelper
parent787387810721d9fba6a5b7fce6e3260171526e01 (diff)
comphelper: compare implemented as subtraction
Change-Id: Ic7abd7dd588339e06b6764659829f35b4ea87adb
Diffstat (limited to 'comphelper')
-rw-r--r--comphelper/source/misc/string.cxx13
1 files changed, 4 insertions, 9 deletions
diff --git a/comphelper/source/misc/string.cxx b/comphelper/source/misc/string.cxx
index b58c67e49152..98391741a13d 100644
--- a/comphelper/source/misc/string.cxx
+++ b/comphelper/source/misc/string.cxx
@@ -323,18 +323,13 @@ sal_Int32 compareNatural( const OUString & rLHS, const OUString & rRHS,
sal_uInt32 nLHS = comphelper::string::decimalStringToNumber(rLHS.copy(nLHSFirstDigitPos, nLHSChunkLen));
sal_uInt32 nRHS = comphelper::string::decimalStringToNumber(rRHS.copy(nRHSFirstDigitPos, nRHSChunkLen));
- nRet = nLHS-nRHS;
- if (nRet != 0)
+ if (nLHS != nRHS)
+ {
+ nRet = (nLHS < nRHS) ? -1 : 1;
break;
+ }
}
- //Squeeze these down to -1, 0, 1 in case there is an assumption those are
- //the only valid returns
- if (nRet > 0)
- nRet = 1;
- else if (nRet < 0)
- nRet = -1;
-
return nRet;
}