From 4e4100ea45343034ae856da85615730db52aaafb Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Mon, 13 May 2024 16:32:36 -0700 Subject: [PATCH] pass shared_ptr value by ref since its only used --- OdbDesignLib/ProductModel/PinConnection.cpp | 15 ++++++++------- OdbDesignLib/ProductModel/PinConnection.h | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/OdbDesignLib/ProductModel/PinConnection.cpp b/OdbDesignLib/ProductModel/PinConnection.cpp index 392463b6..c5e36907 100644 --- a/OdbDesignLib/ProductModel/PinConnection.cpp +++ b/OdbDesignLib/ProductModel/PinConnection.cpp @@ -13,7 +13,7 @@ namespace Odb::Lib::ProductModel //} PinConnection::PinConnection(std::shared_ptr pComponent, std::shared_ptr pPin) - : PinConnection(pComponent, pPin, MakeName(pComponent, pPin)) + : PinConnection(pComponent, pPin, MakeName(*pComponent, *pPin)) { } @@ -24,10 +24,11 @@ namespace Odb::Lib::ProductModel { } - std::string PinConnection::MakeName(std::shared_ptr& pComponent, std::shared_ptr& pPin) + std::string PinConnection::MakeName(const Component& component, const Pin& pin) { - if (pComponent == nullptr || pPin == nullptr) return "Pin::MakeName() FAILED"; - return pComponent->GetRefDes() + "-" + pPin->GetName(); + //if (pComponent == nullptr || pPin == nullptr) return "Pin::MakeName() FAILED"; + //return pComponent->GetRefDes() + "-" + pPin->GetName(); + return component.GetRefDes() + "-" + pin.GetName(); } std::shared_ptr PinConnection::GetPin() const @@ -40,16 +41,16 @@ namespace Odb::Lib::ProductModel return m_pComponent; } - std::unique_ptr PinConnection::to_protobuf() const + std::unique_ptr PinConnection::to_protobuf() const { - auto pPinConnectionMsg = std::make_unique(); + auto pPinConnectionMsg = std::make_unique(); pPinConnectionMsg->set_name(m_name); pPinConnectionMsg->mutable_component()->CopyFrom(*m_pComponent->to_protobuf()); pPinConnectionMsg->mutable_pin()->CopyFrom(*m_pPin->to_protobuf()); return pPinConnectionMsg; } - void PinConnection::from_protobuf(const Odb::Lib::Protobuf::ProductModel::PinConnection& message) + void PinConnection::from_protobuf(const Protobuf::ProductModel::PinConnection& message) { m_name = message.name(); m_pComponent = std::make_shared(); diff --git a/OdbDesignLib/ProductModel/PinConnection.h b/OdbDesignLib/ProductModel/PinConnection.h index 77a256a2..798f0dc5 100644 --- a/OdbDesignLib/ProductModel/PinConnection.h +++ b/OdbDesignLib/ProductModel/PinConnection.h @@ -23,7 +23,7 @@ namespace Odb::Lib::ProductModel std::shared_ptr GetPin() const; std::shared_ptr GetComponent() const; - std::string MakeName(std::shared_ptr& pComponent, std::shared_ptr& pPin); + static std::string MakeName(const Component& component, const Pin& pin); // Inherited via IProtoBuffable std::unique_ptr to_protobuf() const override;