From b26f6e79e12df9d3a0de7a166d0ea273c2917ddb Mon Sep 17 00:00:00 2001 From: Kevin Ahrendt Date: Wed, 29 Jul 2026 08:35:20 -0400 Subject: [PATCH] [voice_assistant] Prepend the model URL prefix in place clang-tidy's performance-inefficient-string-concatenation flags building the absolute URL with operator+, which allocates a temporary for the prefix and another for the result. Insert the prefix instead. --- esphome/components/voice_assistant/voice_assistant.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/esphome/components/voice_assistant/voice_assistant.cpp b/esphome/components/voice_assistant/voice_assistant.cpp index e63afc8138..d383178f39 100644 --- a/esphome/components/voice_assistant/voice_assistant.cpp +++ b/esphome/components/voice_assistant/voice_assistant.cpp @@ -1481,7 +1481,8 @@ void VoiceAssistant::model_load_task(void *params) { if (!model_url.starts_with("http://") && !model_url.starts_with("https://")) { size_t slash_pos = cached_ww.url.find_last_of('/'); if (slash_pos != std::string::npos) { - model_url = cached_ww.url.substr(0, slash_pos + 1) + model_url; + // Prepend in place: building the prefix separately would allocate two temporary strings. + model_url.insert(0, cached_ww.url, 0, slash_pos + 1); } } ESP_LOGD(TAG, "Resolved model URL for %s: %s", id.c_str(), model_url.c_str());