Skip to content

Commit

Permalink
Start using emplace_back
Browse files Browse the repository at this point in the history
  • Loading branch information
hhvrc committed Nov 21, 2024
1 parent 92559fc commit 4a3bd1c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/OtaUpdateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ static bool _tryGetStringList(std::string_view url, std::vector<std::string>& li
continue;
}

list.push_back(std::string(line));
list.emplace_back(line);
}

return true;
Expand Down
6 changes: 1 addition & 5 deletions src/config/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,11 +495,7 @@ uint8_t Config::AddWiFiCredentials(std::string_view ssid, std::string_view passw
return 0;
}

_configData.wifi.credentialsList.push_back({
.id = id,
.ssid = std::string(ssid),
.password = std::string(password),
});
_configData.wifi.credentialsList.emplace_back(id, ssid, password);
_trySaveConfig();

return id;
Expand Down
8 changes: 3 additions & 5 deletions src/serial/command_handlers/CommandEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CommandEntry::CommandEntry(std::string_view name, std::string_view description,
}

CommandArgument& CommandEntry::addArgument(std::string_view name, std::string_view constraint, std::string_view exampleValue, std::vector<std::string_view> constraintExtensions) {
m_arguments.push_back(CommandArgument {name, constraint, exampleValue, constraintExtensions});
m_arguments.push_back({name, constraint, exampleValue, constraintExtensions});
return m_arguments.back();
}

Expand All @@ -23,13 +23,11 @@ CommandGroup::CommandGroup(std::string_view name)
}

CommandEntry& CommandGroup::addCommand(std::string_view description, CommandHandler commandHandler) {
auto cmd = CommandEntry(description, commandHandler);
m_commands.push_back(cmd);
m_commands.emplace_back(description, commandHandler);
return m_commands.back();
}

CommandEntry& CommandGroup::addCommand(std::string_view name, std::string_view description, CommandHandler commandHandler) {
auto cmd = CommandEntry(name, description, commandHandler);
m_commands.push_back(cmd);
m_commands.emplace_back(name, description, commandHandler);
return m_commands.back();
}

1 comment on commit 4a3bd1c

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-format (v18.1.8) reports: 1 file(s) not formatted
  • src/serial/command_handlers/CommandEntry.cpp

Have any feedback or feature suggestions? Share it here.

Please sign in to comment.