Skip to content

Commit 138d4b6

Browse files
committed
Avoid the use of '/' and std::string concat.
Signed-off-by: Jaehyun Kim <[email protected]>
1 parent 5fc69c3 commit 138d4b6

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/dbSta/src/dbNetwork.cc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,18 +1615,22 @@ const char* dbNetwork::pathName(const Net* net) const
16151615
if (parent_module == block_->getTopModule()) {
16161616
return tmpStringCopy(modnet_name.c_str());
16171617
}
1618-
// accumulate a hierachical name, includes top level name
1619-
std::string accumulated_path_name;
1618+
1619+
// Make a full hierarchical name
1620+
fmt::memory_buffer full_path_buf;
16201621
std::vector<dbModule*> parent_hierarchy;
16211622
hierarchy_editor_->getParentHierarchy(parent_module, parent_hierarchy);
16221623
std::reverse(parent_hierarchy.begin(), parent_hierarchy.end());
1624+
auto back_inserter = std::back_inserter(full_path_buf);
16231625
for (auto db_mod : parent_hierarchy) {
1624-
std::string module_name = db_mod->getName();
1625-
accumulated_path_name.append(module_name);
1626-
accumulated_path_name.append("/");
1626+
fmt::format_to(back_inserter,
1627+
"{}{}",
1628+
db_mod->getName(),
1629+
block_->getHierarchyDelimiter());
16271630
}
1628-
accumulated_path_name.append(modnet_name);
1629-
return tmpStringCopy(accumulated_path_name.c_str());
1631+
full_path_buf.append(modnet_name);
1632+
full_path_buf.push_back('\0');
1633+
return tmpStringCopy(full_path_buf.data());
16301634
}
16311635
return nullptr;
16321636
}

0 commit comments

Comments
 (0)