Lots of performance improvements
(In the voice of the kid from sixth sense) I see string copies...
Apparently there are a lot of places we make unnecessary copies. This
fixes all of them.
Not sure how to split this up into smaller patches, or if it even needs
split up. It seems pretty easy to review to me, because basically every
diff is identical.
Change-Id: I22b4ae4f96f7e4082d2bc701098a04f7bed95369
Signed-off-by: Ed Tanous <ed@tanous.net>
Signed-off-by: Wludzik, Jozef <jozef.wludzik@intel.com>
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 1fb8783..05f5d55 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -697,7 +697,7 @@
* @return None
*/
inline void deleteIPv4(const std::string& ifaceId, const std::string& ipHash,
- const std::shared_ptr<AsyncResp> asyncResp)
+ const std::shared_ptr<AsyncResp>& asyncResp)
{
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec) {
@@ -724,7 +724,7 @@
*/
inline void createIPv4(const std::string& ifaceId, uint8_t prefixLength,
const std::string& gateway, const std::string& address,
- std::shared_ptr<AsyncResp> asyncResp)
+ const std::shared_ptr<AsyncResp>& asyncResp)
{
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec) {
@@ -757,7 +757,7 @@
const std::string& id, uint8_t prefixLength,
const std::string& gateway,
const std::string& address,
- std::shared_ptr<AsyncResp> asyncResp)
+ const std::shared_ptr<AsyncResp>& asyncResp)
{
crow::connections::systemBus->async_method_call(
[asyncResp, ifaceId, address, prefixLength,
@@ -794,7 +794,7 @@
* @return None
*/
inline void deleteIPv6(const std::string& ifaceId, const std::string& ipHash,
- const std::shared_ptr<AsyncResp> asyncResp)
+ const std::shared_ptr<AsyncResp>& asyncResp)
{
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec) {
@@ -823,7 +823,7 @@
inline void deleteAndCreateIPv6(const std::string& ifaceId,
const std::string& id, uint8_t prefixLength,
const std::string& address,
- std::shared_ptr<AsyncResp> asyncResp)
+ const std::shared_ptr<AsyncResp>& asyncResp)
{
crow::connections::systemBus->async_method_call(
[asyncResp, ifaceId, address,
@@ -862,7 +862,7 @@
*/
inline void createIPv6(const std::string& ifaceId, uint8_t prefixLength,
const std::string& address,
- std::shared_ptr<AsyncResp> asyncResp)
+ const std::shared_ptr<AsyncResp>& asyncResp)
{
auto createIpHandler = [asyncResp](const boost::system::error_code ec) {
if (ec)
@@ -1080,7 +1080,7 @@
private:
void handleHostnamePatch(const std::string& hostname,
- const std::shared_ptr<AsyncResp> asyncResp)
+ const std::shared_ptr<AsyncResp>& asyncResp)
{
// SHOULD handle host names of up to 255 characters(RFC 1123)
if (hostname.length() > 255)
@@ -1105,7 +1105,7 @@
void handleDomainnamePatch(const std::string& ifaceId,
const std::string& domainname,
- const std::shared_ptr<AsyncResp> asyncResp)
+ const std::shared_ptr<AsyncResp>& asyncResp)
{
std::vector<std::string> vectorDomainname = {domainname};
crow::connections::systemBus->async_method_call(
@@ -1123,7 +1123,7 @@
}
void handleFqdnPatch(const std::string& ifaceId, const std::string& fqdn,
- const std::shared_ptr<AsyncResp> asyncResp)
+ const std::shared_ptr<AsyncResp>& asyncResp)
{
// Total length of FQDN must not exceed 255 characters(RFC 1035)
if (fqdn.length() > 255)
@@ -1203,7 +1203,7 @@
void setDHCPEnabled(const std::string& ifaceId,
const std::string& propertyName, const bool v4Value,
const bool v6Value,
- const std::shared_ptr<AsyncResp> asyncResp)
+ const std::shared_ptr<AsyncResp>& asyncResp)
{
const std::string dhcp = getDhcpEnabledEnumeration(v4Value, v6Value);
crow::connections::systemBus->async_method_call(
@@ -1224,7 +1224,7 @@
void setEthernetInterfaceBoolProperty(
const std::string& ifaceId, const std::string& propertyName,
- const bool& value, const std::shared_ptr<AsyncResp> asyncResp)
+ const bool& value, const std::shared_ptr<AsyncResp>& asyncResp)
{
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec) {
@@ -1243,7 +1243,7 @@
}
void setDHCPv4Config(const std::string& propertyName, const bool& value,
- const std::shared_ptr<AsyncResp> asyncResp)
+ const std::shared_ptr<AsyncResp>& asyncResp)
{
BMCWEB_LOG_DEBUG << propertyName << " = " << value;
crow::connections::systemBus->async_method_call(
@@ -1265,7 +1265,7 @@
void handleDHCPPatch(const std::string& ifaceId,
const EthernetInterfaceData& ethData,
DHCPParameters v4dhcpParms, DHCPParameters v6dhcpParms,
- const std::shared_ptr<AsyncResp> asyncResp)
+ const std::shared_ptr<AsyncResp>& asyncResp)
{
bool ipv4Active = translateDHCPEnabledToBool(ethData.DHCPEnabled, true);
bool ipv6Active =
@@ -1376,7 +1376,8 @@
boost::container::flat_set<IPv4AddressData>::const_iterator
getNextStaticIpEntry(
boost::container::flat_set<IPv4AddressData>::const_iterator head,
- boost::container::flat_set<IPv4AddressData>::const_iterator end)
+ const boost::container::flat_set<IPv4AddressData>::const_iterator&
+ end)
{
for (; head != end; head++)
{
@@ -1391,7 +1392,8 @@
boost::container::flat_set<IPv6AddressData>::const_iterator
getNextStaticIpEntry(
boost::container::flat_set<IPv6AddressData>::const_iterator head,
- boost::container::flat_set<IPv6AddressData>::const_iterator end)
+ const boost::container::flat_set<IPv6AddressData>::const_iterator&
+ end)
{
for (; head != end; head++)
{
@@ -1406,7 +1408,7 @@
void handleIPv4StaticPatch(
const std::string& ifaceId, nlohmann::json& input,
const boost::container::flat_set<IPv4AddressData>& ipv4Data,
- const std::shared_ptr<AsyncResp> asyncResp)
+ const std::shared_ptr<AsyncResp>& asyncResp)
{
if ((!input.is_array()) || input.empty())
{
@@ -1601,7 +1603,7 @@
void handleIPv6StaticAddressesPatch(
const std::string& ifaceId, nlohmann::json& input,
const boost::container::flat_set<IPv6AddressData>& ipv6Data,
- const std::shared_ptr<AsyncResp> asyncResp)
+ const std::shared_ptr<AsyncResp>& asyncResp)
{
if (!input.is_array() || input.empty())
{
@@ -1712,8 +1714,8 @@
}
void parseInterfaceData(
- std::shared_ptr<AsyncResp> asyncResp, const std::string& iface_id,
- const EthernetInterfaceData& ethData,
+ const std::shared_ptr<AsyncResp>& asyncResp,
+ const std::string& iface_id, const EthernetInterfaceData& ethData,
const boost::container::flat_set<IPv4AddressData>& ipv4Data,
const boost::container::flat_set<IPv6AddressData>& ipv6Data)
{