Skip to content

Commit 4a3bd1c

Browse files
committed
Start using emplace_back
1 parent 92559fc commit 4a3bd1c

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

src/OtaUpdateManager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ static bool _tryGetStringList(std::string_view url, std::vector<std::string>& li
450450
continue;
451451
}
452452

453-
list.push_back(std::string(line));
453+
list.emplace_back(line);
454454
}
455455

456456
return true;

src/config/Config.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -495,11 +495,7 @@ uint8_t Config::AddWiFiCredentials(std::string_view ssid, std::string_view passw
495495
return 0;
496496
}
497497

498-
_configData.wifi.credentialsList.push_back({
499-
.id = id,
500-
.ssid = std::string(ssid),
501-
.password = std::string(password),
502-
});
498+
_configData.wifi.credentialsList.emplace_back(id, ssid, password);
503499
_trySaveConfig();
504500

505501
return id;

src/serial/command_handlers/CommandEntry.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ CommandEntry::CommandEntry(std::string_view name, std::string_view description,
1414
}
1515

1616
CommandArgument& CommandEntry::addArgument(std::string_view name, std::string_view constraint, std::string_view exampleValue, std::vector<std::string_view> constraintExtensions) {
17-
m_arguments.push_back(CommandArgument {name, constraint, exampleValue, constraintExtensions});
17+
m_arguments.push_back({name, constraint, exampleValue, constraintExtensions});
1818
return m_arguments.back();
1919
}
2020

@@ -23,13 +23,11 @@ CommandGroup::CommandGroup(std::string_view name)
2323
}
2424

2525
CommandEntry& CommandGroup::addCommand(std::string_view description, CommandHandler commandHandler) {
26-
auto cmd = CommandEntry(description, commandHandler);
27-
m_commands.push_back(cmd);
26+
m_commands.emplace_back(description, commandHandler);
2827
return m_commands.back();
2928
}
3029

3130
CommandEntry& CommandGroup::addCommand(std::string_view name, std::string_view description, CommandHandler commandHandler) {
32-
auto cmd = CommandEntry(name, description, commandHandler);
33-
m_commands.push_back(cmd);
31+
m_commands.emplace_back(name, description, commandHandler);
3432
return m_commands.back();
3533
}

0 commit comments

Comments
 (0)