[Libreoffice-commits] core.git: connectivity/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Mon Sep 27 09:16:03 UTC 2021
connectivity/source/parse/sqliterator.cxx | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
New commits:
commit 89f162abb25168afe942247b77454e45145f1ab8
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Sun Sep 26 20:33:55 2021 +0100
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Mon Sep 27 11:15:29 2021 +0200
ofz#39309 collect the names just once
Change-Id: Iad8a6c80ecac7b8dc380a4c16ccd82650ecc10f5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122656
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/connectivity/source/parse/sqliterator.cxx b/connectivity/source/parse/sqliterator.cxx
index 94df96d39628..95c0cd875a93 100644
--- a/connectivity/source/parse/sqliterator.cxx
+++ b/connectivity/source/parse/sqliterator.cxx
@@ -1718,27 +1718,25 @@ void OSQLParseTreeIterator::setSelectColumnName(::rtl::Reference<OSQLColumns> co
}
}
-OUString OSQLParseTreeIterator::getUniqueColumnName(const OUString & rColumnName) const
+OUString OSQLParseTreeIterator::getUniqueColumnName(const OUString& rColumnName) const
{
- OUString aAlias(rColumnName);
+ ::comphelper::UStringMixLess aCompare(isCaseSensitive());
+ std::vector<OUString> aColumnNames;
+ OUString sPropertyName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME);
+ for (const auto& col : *m_aSelectColumns)
+ aColumnNames.push_back(getString(col->getPropertyValue(sPropertyName)));
+ std::sort(aColumnNames.begin(), aColumnNames.end(), aCompare);
- OSQLColumns::const_iterator aIter = find(
- m_aSelectColumns->begin(),
- m_aSelectColumns->end(),
- aAlias,
- ::comphelper::UStringMixEqual( isCaseSensitive() )
- );
+ if (!std::binary_search(aColumnNames.begin(), aColumnNames.end(), rColumnName, aCompare))
+ return rColumnName;
+
+ OUString aAlias;
sal_Int32 i=1;
- while(aIter != m_aSelectColumns->end())
+ do
{
aAlias = rColumnName + OUString::number(i++);
- aIter = find(
- m_aSelectColumns->begin(),
- m_aSelectColumns->end(),
- aAlias,
- ::comphelper::UStringMixEqual( isCaseSensitive() )
- );
}
+ while (std::binary_search(aColumnNames.begin(), aColumnNames.end(), aAlias, aCompare));
return aAlias;
}
More information about the Libreoffice-commits
mailing list