Skip to content

Commit 0621fee

Browse files
committed
Fixed coverity issue.
- Using std::move() makes the use of makeUniqueName() API more difficult. - I think this implementation w/o moving is better. _____________________________________________________________________________________________ *** CID 1635152: Performance inefficiencies (COPY_INSTEAD_OF_MOVE) /src/dbSta/src/dbEditHierarchy.cc: 400 in sta::dbEditHierarchy::hierarchicalConnect(odb::dbITerm *, odb::dbITerm *, const char *)() 394 std::string base_name = fmt::format( 395 "{}", db_network_->name(db_network_->dbToSta(source_pin_flat_net))); 396 397 // Decide a new unique net name to avoid collisions in the lowest common 398 // hierarchy 399 std::string unique_name >>> CID 1635152: Performance inefficiencies (COPY_INSTEAD_OF_MOVE) >>> "base_name" is passed-by-value as parameter to "makeUniqueName", when it could be moved instead. 400 = makeUniqueName(lowest_common_module, base_name); 401 402 // Create and connect dbModNet 403 source_db_mod_net 404 = dbModNet::create(lowest_common_module, unique_name.c_str()); 405 top_dest_mod_iterm->connect(source_db_mod_net); Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
1 parent 5e4e7f0 commit 0621fee

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/dbSta/src/dbEditHierarchy.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -593,24 +593,22 @@ void dbEditHierarchy::cleanUnusedHierPins(
593593
}
594594

595595
std::string dbEditHierarchy::makeUniqueName(dbModule* module,
596-
std::string name,
596+
const std::string& name,
597597
const char* io_type_str) const
598598
{
599-
std::string base_name = name;
599+
std::string base_name;
600600
if (io_type_str) {
601601
base_name = fmt::format("{}_{}", name, io_type_str);
602+
} else {
603+
base_name = name;
602604
}
603605

604606
std::string unique_name = base_name;
605607
int id = 0;
606608
while (module->findModBTerm(unique_name.c_str())
607609
|| module->getModNet(unique_name.c_str())) {
608610
id++;
609-
if (io_type_str) {
610-
unique_name = fmt::format("{}_{}_{}", name, io_type_str, id);
611-
} else {
612-
unique_name = fmt::format("{}_{}", base_name, id);
613-
}
611+
unique_name = fmt::format("{}_{}", base_name, id);
614612
}
615613
return unique_name;
616614
}

src/dbSta/src/dbEditHierarchy.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class dbEditHierarchy
6363
dbModITerm*& top_mod_iterm) const;
6464
void reassociatePinConnection(Pin* pin);
6565
std::string makeUniqueName(dbModule* module,
66-
std::string name,
66+
const std::string& name,
6767
const char* io_type_str = nullptr) const;
6868

6969
// During the addition of new ports and new wiring we may

0 commit comments

Comments
 (0)