From 38291dec4bd8d3f8a05f23d014a69ab3b24b4f29 Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Fri, 29 Dec 2023 14:13:33 +0100 Subject: [PATCH] Use emplace_back instead of push_back (connectivity/mysqlc) Change-Id: I27b77455919efed2bf8fbc7c063a8e9221ea2816 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161406 Tested-by: Jenkins Reviewed-by: Julien Nabet --- .../mysqlc/mysqlc_databasemetadata.cxx | 40 +++++++++---------- .../drivers/mysqlc/mysqlc_resultset.cxx | 8 ++-- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx b/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx index 901c9bd6dc83..64ce9f63b3b7 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_databasemetadata.cxx @@ -733,18 +733,18 @@ Reference SAL_CALL ODatabaseMetaData::getColumns(const Any& /*catalo std::vector aRow{ Any() }; // 0. element is unused // catalog name - aRow.push_back(Any(xRow->getString(1))); + aRow.emplace_back(xRow->getString(1)); // schema name - aRow.push_back(Any(xRow->getString(2))); + aRow.emplace_back(xRow->getString(2)); // table name - aRow.push_back(Any(xRow->getString(3))); + aRow.emplace_back(xRow->getString(3)); // column name - aRow.push_back(Any(xRow->getString(4))); + aRow.emplace_back(xRow->getString(4)); // data type OUString sDataType = xRow->getString(5); - aRow.push_back(Any(mysqlc_sdbc_driver::mysqlStrToOOOType(sDataType))); + aRow.emplace_back(mysqlc_sdbc_driver::mysqlStrToOOOType(sDataType)); // type name - aRow.push_back(Any(sDataType)); // TODO + aRow.emplace_back(sDataType); // TODO // column size sal_Int32 nColumnSize = 0; OUString sColumnType = xRow->getString(14); @@ -763,34 +763,34 @@ Reference SAL_CALL ODatabaseMetaData::getColumns(const Any& /*catalo nColumnSize = xRow->getShort(7); // numeric precision else nColumnSize = nCharMaxLen; - aRow.push_back(Any(nColumnSize)); - aRow.push_back(Any()); // buffer length - unused + aRow.emplace_back(nColumnSize); + aRow.emplace_back(); // buffer length - unused // decimal digits (scale) - aRow.push_back(Any(xRow->getShort(8))); + aRow.emplace_back(xRow->getShort(8)); // num_prec_radix - aRow.push_back(Any(sal_Int32(10))); + aRow.emplace_back(sal_Int32(10)); // nullable OUString sIsNullable = xRow->getString(13); if (xRow->wasNull()) - aRow.push_back(Any(ColumnValue::NULLABLE_UNKNOWN)); + aRow.emplace_back(ColumnValue::NULLABLE_UNKNOWN); else if (sIsNullable.equalsIgnoreAsciiCase("YES")) - aRow.push_back(Any(ColumnValue::NULLABLE)); + aRow.emplace_back(ColumnValue::NULLABLE); else - aRow.push_back(Any(ColumnValue::NO_NULLS)); + aRow.emplace_back(ColumnValue::NO_NULLS); // remarks - aRow.push_back(Any(xRow->getString(9))); + aRow.emplace_back(xRow->getString(9)); // default - aRow.push_back(Any(xRow->getString(10))); + aRow.emplace_back(xRow->getString(10)); - aRow.push_back(Any{}); // sql_data_type - unused - aRow.push_back(Any{}); // sql_datetime_sub - unused + aRow.emplace_back(); // sql_data_type - unused + aRow.emplace_back(); // sql_datetime_sub - unused // character octet length - aRow.push_back(Any(xRow->getString(11))); + aRow.emplace_back(xRow->getString(11)); // ordinal position - aRow.push_back(Any(xRow->getString(12))); + aRow.emplace_back(xRow->getString(12)); // is nullable - aRow.push_back(Any(sIsNullable)); + aRow.emplace_back(sIsNullable); aRows.push_back(aRow); } lcl_setRows_throw(xResultSet, 1, aRows); diff --git a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx index 5fc0fc9a7d46..397ea7cbab64 100644 --- a/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx +++ b/connectivity/source/drivers/mysqlc/mysqlc_resultset.cxx @@ -139,8 +139,8 @@ void OResultSet::ensureFieldInfoFetched() MYSQL_FIELD* pFields = mysql_fetch_fields(m_pResult); m_aFields.reserve(nFieldCount); for (unsigned i = 0; i < nFieldCount; ++i) - m_aFields.push_back(OUString{ - pFields[i].name, static_cast(strlen(pFields[i].name)), m_encoding }); + m_aFields.emplace_back(pFields[i].name, static_cast(strlen(pFields[i].name)), + m_encoding); } void OResultSet::fetchResult() @@ -156,11 +156,11 @@ void OResultSet::fetchResult() { MYSQL_ROW data = mysql_fetch_row(m_pResult); unsigned long* lengths = mysql_fetch_lengths(m_pResult); - m_aRows.push_back(DataFields{}); + m_aRows.emplace_back(); // MYSQL_ROW is char**, array of strings for (std::size_t col = 0; col < m_aFields.size(); ++col) { - m_aRows.back().push_back(OString{ data[col], static_cast(lengths[col]) }); + m_aRows.back().emplace_back(data[col], static_cast(lengths[col])); } } unsigned errorNum = mysql_errno(m_pMysql);