66*/
77/* *****************************************************************************/
88/*
9- * Copyright (c) 2020-2021 Arm Limited. All rights reserved.
9+ * Copyright (c) 2020-2026 Arm Limited. All rights reserved.
1010 *
1111 * SPDX-License-Identifier: Apache-2.0
1212 */
@@ -709,7 +709,7 @@ void RteDeviceItem::CollectEffectiveProperties(const string& tag, list<RteDevice
709709 RteDeviceProperty* p = dynamic_cast <RteDeviceProperty*>(child);
710710 if (p) {
711711 const string& propPname = p->GetProcessorName ();
712- if (pName. empty () || propPname.empty () || propPname == pName) {
712+ if (propPname.empty () || propPname == pName) {
713713 const string& id = p->GetID ();
714714 RteDeviceProperty* pInserted = RteDeviceProperty::GetPropertyFromList (id, properties);
715715 if (p == pInserted)
@@ -736,8 +736,7 @@ void RteDeviceItem::CollectEffectiveProperties(const string& tag, list<RteDevice
736736// more complicated - gets all available properties
737737void RteDeviceItem::CollectEffectiveProperties (RteDevicePropertyMap& properties, const string& pName) const
738738{
739- RteDevicePropertyMap::iterator dstIt;
740- for (auto [tag, props] : m_properties) {
739+ for (const auto & [tag, props] : m_properties) {
741740 auto dstIt = properties.find (tag);
742741 // add top containers if not yet exist
743742 if (dstIt == properties.end ()) {
@@ -754,17 +753,18 @@ void RteDeviceItem::CollectEffectiveProperties(RteDevicePropertyMap& properties,
754753}
755754
756755
757- void RteDeviceItem::CollectEffectiveProperties (const string& pName)
756+ const RteDevicePropertyMap& RteDeviceItem::CollectEffectiveProperties (const string& pName)
758757{
759758 m_effectiveProperties[pName] = RteEffectiveProperties ();
760759 auto it = m_effectiveProperties.find (pName);
761760 RteDevicePropertyMap& pmap = it->second .m_propertyMap ;
762761 CollectEffectiveProperties (pmap, pName);
763- for (auto [_, l] : pmap) {
762+ for (const auto & [_, l] : pmap) {
764763 for (auto p : l) {
765764 p->CalculateCachedValues ();
766765 }
767766 }
767+ return pmap;
768768}
769769
770770
@@ -779,32 +779,21 @@ const list<RteDeviceProperty*>& RteEffectiveProperties::GetProperties(const stri
779779
780780const RteDevicePropertyMap& RteDeviceItem::GetEffectiveProperties (const string& pName)
781781{
782- if (m_effectiveProperties.empty ()) {
783- for (auto [pn, p] : m_processors) {
784- CollectEffectiveProperties (pn);
782+ if (pName.empty () || contains_key (m_processors, pName)) {
783+ auto itp = m_effectiveProperties.find (pName);
784+ if (itp != m_effectiveProperties.end ()) {
785+ return itp->second .m_propertyMap ;
785786 }
787+ return CollectEffectiveProperties (pName);
786788 }
787-
788- auto itp = m_effectiveProperties.find (pName);
789- if (itp != m_effectiveProperties.end ()) {
790- return itp->second .m_propertyMap ;
791- }
792-
793789 static const RteDevicePropertyMap EMPTY_PROPERTY_MAP ;
794790 return EMPTY_PROPERTY_MAP ;
795791}
796792
797793const list<RteDeviceProperty*>& RteDeviceItem::GetEffectiveProperties (const string& tag, const string& pName)
798794{
799- if (m_effectiveProperties.empty ()) {
800- GetEffectiveProperties (pName);
801- }
802- auto itp = m_effectiveProperties.find (pName);
803- if (itp != m_effectiveProperties.end ()) {
804- const RteEffectiveProperties& effectiveProps = itp->second ;
805- return effectiveProps.GetProperties (tag);
806- }
807- return EMPTY_PROPERTY_LIST ;
795+ const RteDevicePropertyMap& effectivePropMap = GetEffectiveProperties (pName);
796+ return get_or_default_const_ref (effectivePropMap, tag, EMPTY_PROPERTY_LIST );
808797}
809798
810799RteDeviceProperty* RteDeviceItem::GetSingleEffectiveProperty (const string& tag, const string& pName)
@@ -817,11 +806,11 @@ RteDeviceProperty* RteDeviceItem::GetSingleEffectiveProperty(const string& tag,
817806
818807std::list<RteDeviceProperty*> RteDeviceItem::GetAllEffectiveProperties (const std::string& tag)
819808{
820- // Make a copy, simpler to merge with potential processor specific memories
821- list<RteDeviceProperty*> properties = GetEffectiveProperties (tag, RteUtils:: EMPTY_STRING ) ;
809+ // Collect a list of unique properties (by pointer) across all processors for the given tag, without merging/normalizing them
810+ list<RteDeviceProperty*> properties;
822811 // Iterate over processors
823- for ( auto [pname, _] : GetProcessors ()) {
824- // Collect processor - unique memories
812+ for ( const auto & [pname, _] : GetProcessors ()) {
813+ // Collect processor-specific properties for this tag
825814 const list<RteDeviceProperty*>& procProps = GetEffectiveProperties (tag, pname);
826815 for (auto p : procProps) {
827816 if (std::find (properties.begin (), properties.end (), p) == properties.end ()) {
@@ -1226,7 +1215,7 @@ string RteDeviceItemAggregate::GetSummaryString() const
12261215 // Memory (RAM/ROM)
12271216 unsigned long long ramSize = 0 , romSize = 0 ;
12281217 // Get all memory properties
1229- list<RteDeviceProperty*> mems = item->GetAllEffectiveProperties (" memory" );
1218+ const list<RteDeviceProperty*>& mems = item->GetAllEffectiveProperties (" memory" );
12301219 for (auto memsIt = mems.begin (); memsIt != mems.end (); ++memsIt) {
12311220 RteDeviceMemory* mem = dynamic_cast <RteDeviceMemory*>(*memsIt);
12321221 if (!mem) {
0 commit comments