Applied performance-for-range-copy clang-tidy fixes

This commit is contained in:
Bartek Kryza
2022-12-21 18:14:13 +01:00
parent 14128374ef
commit 71c772ac04
3 changed files with 31 additions and 26 deletions

View File

@@ -287,7 +287,7 @@ template <typename C, typename D>
void generator<C, D>::generate_notes( void generator<C, D>::generate_notes(
std::ostream &ostr, const model::element &e) const std::ostream &ostr, const model::element &e) const
{ {
for (auto decorator : e.decorators()) { for (const auto &decorator : e.decorators()) {
auto note = std::dynamic_pointer_cast<decorators::note>(decorator); auto note = std::dynamic_pointer_cast<decorators::note>(decorator);
if (note && note->applies_to_diagram(m_config.name)) { if (note && note->applies_to_diagram(m_config.name)) {
ostr << "note " << note->position << " of " << e.alias() << '\n' ostr << "note " << note->position << " of " << e.alias() << '\n'

View File

@@ -59,7 +59,7 @@ decorated_element::get_relationship() const
std::string decorated_element::style_spec() const std::string decorated_element::style_spec() const
{ {
for (auto d : decorators_) for (const auto &d : decorators_)
if (std::dynamic_pointer_cast<decorators::style>(d)) if (std::dynamic_pointer_cast<decorators::style>(d))
return std::dynamic_pointer_cast<decorators::style>(d)->spec; return std::dynamic_pointer_cast<decorators::style>(d)->spec;
@@ -75,14 +75,14 @@ decorated_element::decorators() const
void decorated_element::add_decorators( void decorated_element::add_decorators(
const std::vector<std::shared_ptr<decorators::decorator>> &decorators) const std::vector<std::shared_ptr<decorators::decorator>> &decorators)
{ {
for (auto d : decorators) { for (const auto &d : decorators) {
decorators_.push_back(d); decorators_.push_back(d);
} }
} }
void decorated_element::append(const decorated_element &de) void decorated_element::append(const decorated_element &de)
{ {
for (auto d : de.decorators()) { for (const auto &d : de.decorators()) {
decorators_.push_back(d); decorators_.push_back(d);
} }
} }

View File

@@ -87,11 +87,14 @@ void clang_visitor::visit(
clang::dyn_cast<TParamCommandComment>(block), traits, cmt); clang::dyn_cast<TParamCommandComment>(block), traits, cmt);
} }
else if (block_kind == Comment::BlockCommandCommentKind) { else if (block_kind == Comment::BlockCommandCommentKind) {
const auto *command = clang::dyn_cast<BlockCommandComment>(block); if (const auto *command =
clang::dyn_cast<BlockCommandComment>(block);
command != nullptr) {
const auto *command_info = const auto *command_info =
traits.getCommandInfo(command->getCommandID()); traits.getCommandInfo(command->getCommandID());
if (command_info->IsBlockCommand && command_info->NumArgs == 0u) { if (command_info->IsBlockCommand &&
command_info->NumArgs == 0u) {
// Visit block command with a single text argument, e.g.: // Visit block command with a single text argument, e.g.:
// \brief text // \brief text
// \todo text // \todo text
@@ -102,7 +105,8 @@ void clang_visitor::visit(
// Visit function param block: // Visit function param block:
// \param arg text // \param arg text
visit_param_command( visit_param_command(
clang::dyn_cast<ParamCommandComment>(command), traits, cmt); clang::dyn_cast<ParamCommandComment>(command), traits,
cmt);
} }
else if (command_info->IsTParamCommand) { else if (command_info->IsTParamCommand) {
// Visit template param block: // Visit template param block:
@@ -113,6 +117,7 @@ void clang_visitor::visit(
} }
} }
} }
}
e.set_comment(cmt); e.set_comment(cmt);
} }