rmp: adjust naming to Google-style (excluding method names)#10193
Conversation
Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
There was a problem hiding this comment.
Code Review
This pull request refactors naming conventions for enums and variables to a consistent style and adds linting suppressions for external library declarations. Feedback focuses on optimizing loops in Restructure.cpp by using references to avoid string copies and caching redundant function calls, as well as improving readability by storing repeated boolean conditions.
| for (auto pin_name : *error) { | ||
| debugPrint(logger_, RMP, "remap", 1, "Unconstrained pin: {}", pin_name); | ||
| if (!first && open_sta_->getDbNetwork()->findPin(pin_name.c_str())) { | ||
| ends.insert(open_sta_->getDbNetwork()->findPin(pin_name.c_str())); | ||
| } | ||
| first = false; | ||
| } |
There was a problem hiding this comment.
Iterating by value causes unnecessary string copies. Additionally, following the principle of analyzing loop structures to avoid redundancy, findPin should not be called multiple times for the same pin. Consider using a reference and caching the result to improve efficiency.
| for (auto pin_name : *error) { | |
| debugPrint(logger_, RMP, "remap", 1, "Unconstrained pin: {}", pin_name); | |
| if (!first && open_sta_->getDbNetwork()->findPin(pin_name.c_str())) { | |
| ends.insert(open_sta_->getDbNetwork()->findPin(pin_name.c_str())); | |
| } | |
| first = false; | |
| } | |
| for (const auto& pin_name : *error) { | |
| debugPrint(logger_, RMP, "remap", 1, "Unconstrained pin: {}", pin_name); | |
| if (!first) { | |
| if (auto* pin = open_sta_->getDbNetwork()->findPin(pin_name.c_str())) { | |
| ends.insert(pin); | |
| } | |
| } | |
| first = false; | |
| } |
References
- When analyzing code within a loop, consider the entire loop structure to identify and remove redundant operations within the loop body.
| for (auto pin_name : *error) { | ||
| debugPrint(logger_, RMP, "remap", 1, "Unclocked pin: {}", pin_name); | ||
| if (!first && open_sta_->getDbNetwork()->findPin(pin_name.c_str())) { | ||
| ends.insert(open_sta_->getDbNetwork()->findPin(pin_name.c_str())); | ||
| } | ||
| first = false; | ||
| } |
There was a problem hiding this comment.
Iterating by value causes unnecessary string copies. Additionally, following the principle of analyzing loop structures to avoid redundancy, findPin should not be called multiple times for the same pin. Consider using a reference and caching the result to improve efficiency.
for (const auto& pin_name : *error) {
debugPrint(logger_, RMP, "remap", 1, "Unclocked pin: {}", pin_name);
if (!first) {
if (auto* pin = open_sta_->getDbNetwork()->findPin(pin_name.c_str())) {
ends.insert(pin);
}
}
first = false;
}References
- When analyzing code within a loop, consider the entire loop structure to identify and remove redundant operations within the loop body.
| odb::dbMaster* const_master = (pin_val == sta::LogicValue::one) | ||
| ? hicell_master | ||
| : locell_master; | ||
| odb::dbMTerm* const_port | ||
| = (pinVal == sta::LogicValue::one) ? hiterm : loterm; | ||
| = (pin_val == sta::LogicValue::one) ? hiterm : loterm; |
There was a problem hiding this comment.
The condition pin_val == sta::LogicValue::one is evaluated twice. Storing the result in a descriptive boolean variable improves readability and provides a minor performance optimization.
| odb::dbMaster* const_master = (pin_val == sta::LogicValue::one) | |
| ? hicell_master | |
| : locell_master; | |
| odb::dbMTerm* const_port | |
| = (pinVal == sta::LogicValue::one) ? hiterm : loterm; | |
| = (pin_val == sta::LogicValue::one) ? hiterm : loterm; | |
| const bool is_one = (pin_val == sta::LogicValue::one); | |
| odb::dbMaster* const_master = is_one ? hicell_master : locell_master; | |
| odb::dbMTerm* const_port = is_one ? hiterm : loterm; |
| debugPrint(logger_, RMP, "remap", 1, "Unconstrained pin: {}", pinName); | ||
| if (!first && open_sta_->getDbNetwork()->findPin(pinName.c_str())) { | ||
| ends.insert(open_sta_->getDbNetwork()->findPin(pinName.c_str())); | ||
| for (auto pin_name : *error) { |
There was a problem hiding this comment.
warning: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy]
| for (auto pin_name : *error) { | |
| for (const auto& pin_name : *error) { |
| ends.insert(open_sta_->getDbNetwork()->findPin(pinName.c_str())); | ||
| for (auto pin_name : *error) { | ||
| debugPrint(logger_, RMP, "remap", 1, "Unconstrained pin: {}", pin_name); | ||
| if (!first && open_sta_->getDbNetwork()->findPin(pin_name.c_str())) { |
There was a problem hiding this comment.
warning: redundant call to 'c_str' [readability-redundant-string-cstr]
| if (!first && open_sta_->getDbNetwork()->findPin(pin_name.c_str())) { | |
| if (!first && open_sta_->getDbNetwork()->findPin(pin_name)) { |
| for (auto pin_name : *error) { | ||
| debugPrint(logger_, RMP, "remap", 1, "Unconstrained pin: {}", pin_name); | ||
| if (!first && open_sta_->getDbNetwork()->findPin(pin_name.c_str())) { | ||
| ends.insert(open_sta_->getDbNetwork()->findPin(pin_name.c_str())); |
There was a problem hiding this comment.
warning: redundant call to 'c_str' [readability-redundant-string-cstr]
| ends.insert(open_sta_->getDbNetwork()->findPin(pin_name.c_str())); | |
| ends.insert(open_sta_->getDbNetwork()->findPin(pin_name)); |
| debugPrint(logger_, RMP, "remap", 1, "Unclocked pin: {}", pinName); | ||
| if (!first && open_sta_->getDbNetwork()->findPin(pinName.c_str())) { | ||
| ends.insert(open_sta_->getDbNetwork()->findPin(pinName.c_str())); | ||
| for (auto pin_name : *error) { |
There was a problem hiding this comment.
warning: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy]
| for (auto pin_name : *error) { | |
| for (const auto& pin_name : *error) { |
| ends.insert(open_sta_->getDbNetwork()->findPin(pinName.c_str())); | ||
| for (auto pin_name : *error) { | ||
| debugPrint(logger_, RMP, "remap", 1, "Unclocked pin: {}", pin_name); | ||
| if (!first && open_sta_->getDbNetwork()->findPin(pin_name.c_str())) { |
There was a problem hiding this comment.
warning: redundant call to 'c_str' [readability-redundant-string-cstr]
| if (!first && open_sta_->getDbNetwork()->findPin(pin_name.c_str())) { | |
| if (!first && open_sta_->getDbNetwork()->findPin(pin_name)) { |
| for (auto pin_name : *error) { | ||
| debugPrint(logger_, RMP, "remap", 1, "Unclocked pin: {}", pin_name); | ||
| if (!first && open_sta_->getDbNetwork()->findPin(pin_name.c_str())) { | ||
| ends.insert(open_sta_->getDbNetwork()->findPin(pin_name.c_str())); |
There was a problem hiding this comment.
warning: redundant call to 'c_str' [readability-redundant-string-cstr]
| ends.insert(open_sta_->getDbNetwork()->findPin(pin_name.c_str())); | |
| ends.insert(open_sta_->getDbNetwork()->findPin(pin_name)); |
3295560
into
The-OpenROAD-Project:master
Summary
adjust naming to Google-style (excluding method names)
Type of Change
Impact
None
Verification
./etc/Build.sh).