From 8512ccd7c003e195bf3d3c56a29ee6c9b199a125 Mon Sep 17 00:00:00 2001 From: andyfox-rushc Date: Mon, 30 Dec 2024 21:06:02 -0800 Subject: [PATCH] Attempt to avoid unnecessary memory allocation when accumulating hierarchical name, replace + with append Signed-off-by: andyfox-rushc --- src/dbSta/src/dbNetwork.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/dbSta/src/dbNetwork.cc b/src/dbSta/src/dbNetwork.cc index cdb860eb1e7..4b30d051cb6 100644 --- a/src/dbSta/src/dbNetwork.cc +++ b/src/dbSta/src/dbNetwork.cc @@ -77,6 +77,9 @@ Recommended conclusion: use map for concrete cells. They are invariant. */ #include "db_sta/dbNetwork.hh" +#include +#include + #include "odb/db.h" #include "sta/Liberty.hh" #include "sta/PatternMatch.hh" @@ -1531,21 +1534,22 @@ const char* dbNetwork::pathName(const Net* net) const if (modnet) { std::string modnet_name = modnet->getName(); - // if a top net, don't prefix with top module name dbModule* parent_module = modnet->getParent(); if (parent_module == block_->getTopModule()) { return tmpStringCopy(modnet_name.c_str()); } - // accumulate a hierachical name, includes top level name - std::string accumulated_path_name = modnet_name; + std::string accumulated_path_name; std::vector parent_hierarchy; getParentHierarchy(parent_module, parent_hierarchy); + std::reverse(parent_hierarchy.begin(), parent_hierarchy.end()); for (auto db_mod : parent_hierarchy) { std::string module_name = db_mod->getName(); - accumulated_path_name = module_name + "/" + accumulated_path_name; + accumulated_path_name.append(module_name); + accumulated_path_name.append("/"); } + accumulated_path_name.append(modnet_name); return tmpStringCopy(accumulated_path_name.c_str()); } return nullptr;