[text] Store pattern as const char* to reduce memory usage

This commit is contained in:
J. Nick Koston
2025-12-06 23:49:09 -06:00
parent 1f271e7c10
commit 0610b3a60a
4 changed files with 7 additions and 8 deletions
+1 -1
View File
@@ -1211,7 +1211,7 @@ std::string WebServer::text_json(text::Text *obj, const std::string &value, Json
set_json_icon_state_value(root, obj, "text", state, value, start_config);
root[ESPHOME_F("min_length")] = obj->traits.get_min_length();
root[ESPHOME_F("max_length")] = obj->traits.get_max_length();
root[ESPHOME_F("pattern")] = obj->traits.get_pattern();
root[ESPHOME_F("pattern")] = obj->traits.get_pattern_ref();
if (start_config == DETAIL_ALL) {
root[ESPHOME_F("mode")] = (int) obj->traits.get_mode();
this->add_sorting_info_(root, obj);
@@ -142,7 +142,7 @@ void WebServer::handle_index_request(AsyncWebServerRequest *request) {
stream.print(R"(" maxlength=")");
stream.print(text->traits.get_max_length());
stream.print(R"(" pattern=")");
stream.print(text->traits.get_pattern().c_str());
stream.print(text->traits.get_pattern_ref().c_str());
stream.print(R"(" value=")");
stream.print(text->state.c_str());
stream.print(R"("/>)");