Reduce heap allocations by getting rid of temporary std::list and std::string

This commit is contained in:
2025-05-28 15:43:42 +02:00
parent b8cdd373f4
commit 1d49013fc6
10 changed files with 44 additions and 40 deletions
@@ -28,9 +28,9 @@ namespace dce_commands {
* @param fail_phrase String to be present in the reply to fail this command
* @param timeout_ms Timeout in ms
*/
command_result generic_command(CommandableIf *t, const std::string &command,
const std::string &pass_phrase,
const std::string &fail_phrase, uint32_t timeout_ms);
command_result generic_command(CommandableIf *t, std::string_view command,
std::string_view pass_phrase,
std::string_view fail_phrase, uint32_t timeout_ms);
/**
* @brief Declaration of all commands is generated from esp_modem_command_declare.inc
*/
@@ -496,8 +496,8 @@ command_result SQNGM02S::connect(PdpContext &pdp)
return res;
}
//wait for +CEREG: 5 or +CEREG: 1.
const auto pass = std::list<std::string_view>({"+CEREG: 1", "+CEREG: 5"});
const auto fail = std::list<std::string_view>({"ERROR"});
const std::string_view pass[] {"+CEREG: 1", "+CEREG: 5"};
const std::string_view fail[] {"ERROR"};
res = esp_modem::dce_commands::generic_command(dte.get(), "", pass, fail, 1200000);
if (res != command_result::OK) {
config_network_registration_urc(0);