From a5ceb2cf2976644f1ab87440e774df2ed0a19b11 Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Tue, 13 Dec 2011 00:14:44 +0100 Subject: [PATCH] TopologyRead string handling optimization --- src/topology-read/model/topology-reader.cc | 10 +++++----- src/topology-read/model/topology-reader.h | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/topology-read/model/topology-reader.cc b/src/topology-read/model/topology-reader.cc index 8921b9f31..8a7e09b7f 100644 --- a/src/topology-read/model/topology-reader.cc +++ b/src/topology-read/model/topology-reader.cc @@ -49,7 +49,7 @@ TopologyReader::~TopologyReader () } void -TopologyReader::SetFileName (const std::string fileName) +TopologyReader::SetFileName (const std::string &fileName) { m_fileName = fileName; } @@ -94,7 +94,7 @@ TopologyReader::AddLink (Link link) } -TopologyReader::Link::Link ( Ptr fromPtr, std::string fromName, Ptr toPtr, std::string toName ) +TopologyReader::Link::Link ( Ptr fromPtr, const std::string &fromName, Ptr toPtr, const std::string &toName ) { m_fromPtr = fromPtr; m_fromName = fromName; @@ -131,14 +131,14 @@ TopologyReader::Link::GetToNodeName (void) const } std::string -TopologyReader::Link::GetAttribute (std::string name) const +TopologyReader::Link::GetAttribute (const std::string &name) const { NS_ASSERT_MSG (m_linkAttr.find (name) == m_linkAttr.end (), "Requested topology link attribute not found"); return m_linkAttr.find (name)->second; } bool -TopologyReader::Link::GetAttributeFailSafe (std::string name, std::string &value) const +TopologyReader::Link::GetAttributeFailSafe (const std::string &name, std::string &value) const { if ( m_linkAttr.find (name) == m_linkAttr.end () ) { @@ -149,7 +149,7 @@ TopologyReader::Link::GetAttributeFailSafe (std::string name, std::string &value } void -TopologyReader::Link::SetAttribute (std::string name, std::string &value) +TopologyReader::Link::SetAttribute (const std::string &name, const std::string &value) { m_linkAttr[name] = value; } diff --git a/src/topology-read/model/topology-reader.h b/src/topology-read/model/topology-reader.h index 47648902d..865b7d379 100644 --- a/src/topology-read/model/topology-reader.h +++ b/src/topology-read/model/topology-reader.h @@ -57,7 +57,7 @@ public: /** * \brief Constant iterator to scan the map of link attributes. */ - typedef std::map::const_iterator ConstAttributesIterator; + typedef std::map::const_iterator ConstAttributesIterator; /** * \brief Constructor @@ -66,7 +66,7 @@ public: * \param toPtr Ptr to the node the link is directed to * \param toName name of the node the link is directed to */ - Link ( Ptr fromPtr, std::string fromName, Ptr toPtr, std::string toName ); + Link ( Ptr fromPtr, const std::string &fromName, Ptr toPtr, const std::string &toName ); /** * \brief Returns a Ptr to the "from" node of the link @@ -95,7 +95,7 @@ public: * * \return the value of the attribute */ - std::string GetAttribute (std::string name) const; + std::string GetAttribute (const std::string &name) const; /** * \brief Returns the value of a link attribute. * \param name the name of the attribute @@ -103,13 +103,13 @@ public: * * \return true if the attribute was defined, false otherwise. */ - bool GetAttributeFailSafe (std::string name, std::string &value) const; + bool GetAttributeFailSafe (const std::string &name, std::string &value) const; /** * \brief Sets an arbitrary link attribute. * \param name the name of the attribute * \param value the value of the attribute */ - void SetAttribute (std::string name, std::string &value); + void SetAttribute (const std::string &name, const std::string &value); /** * \brief Returns an iterator to the begin of the attributes. * \return a const iterator to the first attribute of a link. @@ -127,7 +127,7 @@ private: Ptr< Node > m_fromPtr; std::string m_toName; Ptr< Node > m_toPtr; - std::map m_linkAttr; + std::map m_linkAttr; }; /** @@ -157,7 +157,7 @@ private: * \brief Sets the input file name. * \param fileName the input file name. */ - void SetFileName (const std::string fileName); + void SetFileName (const std::string &fileName); /** * \brief Returns the input file name.