[web_server] Store method/domain comparison strings in flash on ESP8266 (#13205)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
J. Nick KostonandCopilot authored and GitHub committed 2026-01-14 09:18:17 -05:00
1 parent d6fa1d6e5f
commit 068b497b9b
3 files changed
+72 -44

No files matched your search

+21
View File
@@ -11,6 +11,10 @@
#include "esphome/components/json/json_util.h"
#endif // USE_JSON
#ifdef USE_ESP8266
#include <pgmspace.h>
#endif // USE_ESP8266
namespace esphome {
/**
@@ -107,6 +111,23 @@ inline bool operator!=(const StringRef &lhs, const char *rhs) { return !(lhs ==
inline bool operator!=(const char *lhs, const StringRef &rhs) { return !(rhs == lhs); }
#ifdef USE_ESP8266
inline bool operator==(const StringRef &lhs, const __FlashStringHelper *rhs) {
PGM_P p = reinterpret_cast<PGM_P>(rhs);
size_t rhs_len = strlen_P(p);
if (lhs.size() != rhs_len) {
return false;
}
return memcmp_P(lhs.c_str(), p, rhs_len) == 0;
}
inline bool operator==(const __FlashStringHelper *lhs, const StringRef &rhs) { return rhs == lhs; }
inline bool operator!=(const StringRef &lhs, const __FlashStringHelper *rhs) { return !(lhs == rhs); }
inline bool operator!=(const __FlashStringHelper *lhs, const StringRef &rhs) { return !(rhs == lhs); }
#endif // USE_ESP8266
inline bool operator<(const StringRef &lhs, const StringRef &rhs) {
return std::lexicographical_compare(std::begin(lhs), std::end(lhs), std::begin(rhs), std::end(rhs));
}