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,29 +87,34 @@ 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 =
const auto *command_info = clang::dyn_cast<BlockCommandComment>(block);
traits.getCommandInfo(command->getCommandID()); command != nullptr) {
const auto *command_info =
traits.getCommandInfo(command->getCommandID());
if (command_info->IsBlockCommand && command_info->NumArgs == 0u) { if (command_info->IsBlockCommand &&
// Visit block command with a single text argument, e.g.: command_info->NumArgs == 0u) {
// \brief text // Visit block command with a single text argument, e.g.:
// \todo text // \brief text
// ... // \todo text
visit_block_command(command, traits, cmt); // ...
} visit_block_command(command, traits, cmt);
else if (command_info->IsParamCommand) { }
// Visit function param block: else if (command_info->IsParamCommand) {
// \param arg text // Visit function param block:
visit_param_command( // \param arg text
clang::dyn_cast<ParamCommandComment>(command), traits, cmt); visit_param_command(
} clang::dyn_cast<ParamCommandComment>(command), traits,
else if (command_info->IsTParamCommand) { cmt);
// Visit template param block: }
// \tparam typename text else if (command_info->IsTParamCommand) {
visit_tparam_command( // Visit template param block:
clang::dyn_cast<TParamCommandComment>(command), traits, // \tparam typename text
cmt); visit_tparam_command(
clang::dyn_cast<TParamCommandComment>(command), traits,
cmt);
}
} }
} }
} }