From 6dbae37b8d2d2d1ecad85c772fd684803b5a52cb Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 28 Aug 2018 11:15:47 +0200 Subject: loplugin:constantparam (1) Change-Id: I25077e391ecca1b678062d261a83d88daadf0a58 Reviewed-on: https://gerrit.libreoffice.org/59701 Tested-by: Jenkins Reviewed-by: Noel Grandin --- comphelper/source/misc/sequence.cxx | 49 ++++++------------------------------- 1 file changed, 7 insertions(+), 42 deletions(-) (limited to 'comphelper') diff --git a/comphelper/source/misc/sequence.cxx b/comphelper/source/misc/sequence.cxx index 9236ee7d9bb6..81079de2223c 100644 --- a/comphelper/source/misc/sequence.cxx +++ b/comphelper/source/misc/sequence.cxx @@ -21,56 +21,21 @@ namespace comphelper { -css::uno::Sequence findValue(const css::uno::Sequence< OUString >& _rList, const OUString& _rValue, bool _bOnlyFirst) +sal_Int32 findValue(const css::uno::Sequence< OUString >& _rList, const OUString& _rValue) { sal_Int32 nLength = _rList.getLength(); - if( _bOnlyFirst ) + // at which position do I find the value? + const OUString* pTArray = _rList.getConstArray(); + for (sal_Int32 i = 0; i < nLength; ++i, ++pTArray) { - // at which position do I find the value? - sal_Int32 nPos = -1; - const OUString* pTArray = _rList.getConstArray(); - for (sal_Int32 i = 0; i < nLength; ++i, ++pTArray) + if( *pTArray == _rValue ) { - if( *pTArray == _rValue ) - { - nPos = i; - break; - } + return i; } - - // fill sequence - if( nPos>-1 ) - { - css::uno::Sequence aRetSeq( 1 ); - aRetSeq.getArray()[0] = static_cast(nPos); - - return aRetSeq; - } - - return css::uno::Sequence(); - } - else - { - css::uno::Sequence aRetSeq( nLength ); - sal_Int16* pReturn = aRetSeq.getArray(); - - // how often does the value occur? - const OUString* pTArray = _rList.getConstArray(); - for (sal_Int32 i = 0; i < nLength; ++i, ++pTArray) - { - if( *pTArray == _rValue ) - { - *pReturn = static_cast(i); - ++pReturn; - } - } - - aRetSeq.realloc(pReturn - aRetSeq.getArray()); - return aRetSeq; - } + return -1; } } // namespace comphelper -- cgit