Skip to content

Commit 6a0442f

Browse files
committed
odb: Avoid unnecessary copy in makeUniqueHierName
Build the unique hierarchy name directly from the sanitized base name. Coverity reports COPY_INSTEAD_OF_MOVE because the no-suffix path copies a local string through the ternary expression. Start with the sanitized name and append the suffix only when present so neither path needs an extra copy/move temporary. Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
1 parent 42457f2 commit 6a0442f

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/odb/src/db/dbInsertBuffer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,10 @@ std::string dbInsertBuffer::makeUniqueHierName(const dbModule* module,
539539
const char* suffix) const
540540
{
541541
// insertBuffer only punches scalar hierarchy ports, never bus ports.
542-
std::string scalar_base_name = replaceBracketsWithUnderscores(base_name);
543-
std::string name
544-
= (suffix == nullptr) ? scalar_base_name : scalar_base_name + suffix;
542+
std::string name = replaceBracketsWithUnderscores(base_name);
543+
if (suffix != nullptr) {
544+
name += suffix;
545+
}
545546
std::string full = block_->makeNewNetName(
546547
module, name.c_str(), dbNameUniquifyType::IF_NEEDED_WITH_UNDERSCORE);
547548
return std::string(block_->getBaseName(full.c_str()));

0 commit comments

Comments
 (0)