connectivity/source/commontools/DateConversion.cxx | 11 +---------- connectivity/source/commontools/predicateinput.cxx | 12 +----------- 2 files changed, 2 insertions(+), 21 deletions(-)
New commits: commit 8926e891f9865f3857cfc00ccab1adce9077dd4c Author: Julien Nabet <[email protected]> AuthorDate: Sun Sep 4 13:00:44 2022 +0200 Commit: Caolán McNamara <[email protected]> CommitDate: Sun Sep 4 14:46:23 2022 +0200 Simplify by using replace instead of replaceAt in 2 loops in connectivity Change-Id: Ia89ab8131be9cda8b5365fa41769a32409c35a79 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139358 Tested-by: Jenkins Tested-by: Caolán McNamara <[email protected]> Reviewed-by: Caolán McNamara <[email protected]> diff --git a/connectivity/source/commontools/DateConversion.cxx b/connectivity/source/commontools/DateConversion.cxx index 6f4e2e36ee75..38e94f320e48 100644 --- a/connectivity/source/commontools/DateConversion.cxx +++ b/connectivity/source/commontools/DateConversion.cxx @@ -83,16 +83,7 @@ OUString DBTypeConversion::toSQLString(sal_Int32 eType, const Any& _rVal, { OUString aTemp; _rxTypeConverter->convertToSimpleType(_rVal, TypeClass_STRING) >>= aTemp; - sal_Int32 nIndex = sal_Int32(-2); - static const OUStringLiteral sQuot(u"\'"); - do - { - nIndex += 2; - nIndex = aTemp.indexOf(sQuot,nIndex); - if(nIndex != -1) - aTemp = aTemp.replaceAt(nIndex,sQuot.getLength(), u"\'\'"); - } while (nIndex != -1); - + aTemp = aTemp.replaceAll(u"\'", u"\'\'"); aRet.append(aTemp); } aRet.append("'"); diff --git a/connectivity/source/commontools/predicateinput.cxx b/connectivity/source/commontools/predicateinput.cxx index e445ecbd1397..cbeaf511a943 100644 --- a/connectivity/source/commontools/predicateinput.cxx +++ b/connectivity/source/commontools/predicateinput.cxx @@ -147,17 +147,7 @@ namespace dbtools ) ) { - static const char sSingleQuote[] = "'"; - - sal_Int32 nIndex = -1; - sal_Int32 nTemp = 0; - while ( -1 != ( nIndex = sQuoted.indexOf( '\'',nTemp ) ) ) - { - sQuoted = sQuoted.replaceAt( nIndex, 1, u"''" ); - nTemp = nIndex+2; - } - - sQuoted = sSingleQuote + sQuoted + sSingleQuote; + sQuoted = u"'" + sQuoted.replaceAll(u"'", u"''") + u"'"; } pReturn = const_cast< OSQLParser& >( m_aParser ).predicateTree( _rErrorMessage, sQuoted, m_xFormatter, _rxField ); }
