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(
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);
if (note && note->applies_to_diagram(m_config.name)) {
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
{
for (auto d : decorators_)
for (const auto &d : decorators_)
if (std::dynamic_pointer_cast<decorators::style>(d))
return std::dynamic_pointer_cast<decorators::style>(d)->spec;
@@ -75,14 +75,14 @@ decorated_element::decorators() const
void decorated_element::add_decorators(
const std::vector<std::shared_ptr<decorators::decorator>> &decorators)
{
for (auto d : decorators) {
for (const auto &d : decorators) {
decorators_.push_back(d);
}
}
void decorated_element::append(const decorated_element &de)
{
for (auto d : de.decorators()) {
for (const auto &d : de.decorators()) {
decorators_.push_back(d);
}
}

View File

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