Kaydet (Commit) b91cb7d1 authored tarafından Jochen Nitschke's avatar Jochen Nitschke Kaydeden (comit) Noel Grandin

cppcheck: uselessCallsRemove

std::remove returns a past the end iterator which should be used
for the reallocation.

This makes the code more robust. Previously it only worked if
there was exactly one value with type XGeneratedResultSet in the
Sequence.

Change-Id: Ia2db1252ba8fe682dbc55d9722eaa62ed596e297
Reviewed-on: https://gerrit.libreoffice.org/39724Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst fb89b081
......@@ -133,9 +133,9 @@ Sequence< Type > SAL_CALL java_sql_Statement_Base::getTypes( )
Sequence< Type > aOldTypes = java_sql_Statement_BASE::getTypes();
if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() )
{
std::remove(aOldTypes.begin(), aOldTypes.end(),
cppu::UnoType<XGeneratedResultSet>::get());
aOldTypes.realloc(aOldTypes.getLength() - 1);
auto newEnd = std::remove(aOldTypes.begin(), aOldTypes.end(),
cppu::UnoType<XGeneratedResultSet>::get());
aOldTypes.realloc(std::distance(aOldTypes.begin(), newEnd));
}
return ::comphelper::concatSequences(aTypes.getTypes(),aOldTypes);
......
......@@ -139,9 +139,9 @@ Sequence< Type > SAL_CALL OStatement_Base::getTypes( )
Sequence< Type > aOldTypes = OStatement_BASE::getTypes();
if ( m_pConnection.is() && !m_pConnection->isAutoRetrievingEnabled() )
{
std::remove(aOldTypes.begin(), aOldTypes.end(),
cppu::UnoType<XGeneratedResultSet>::get());
aOldTypes.realloc(aOldTypes.getLength() - 1);
auto newEnd = std::remove(aOldTypes.begin(), aOldTypes.end(),
cppu::UnoType<XGeneratedResultSet>::get());
aOldTypes.realloc(std::distance(aOldTypes.begin(), newEnd));
}
return ::comphelper::concatSequences(aTypes.getTypes(),aOldTypes);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment