mirror of
https://github.com/esphome/esphome.git
synced 2025-07-29 06:36:45 +00:00
Eliminate web_server_idf guard variable to save 8 bytes RAM (#9344)
This commit is contained in:
parent
0bc18a8281
commit
4673a5b48c
@ -37,6 +37,15 @@ namespace web_server_idf {
|
|||||||
|
|
||||||
static const char *const TAG = "web_server_idf";
|
static const char *const TAG = "web_server_idf";
|
||||||
|
|
||||||
|
// Global instance to avoid guard variable (saves 8 bytes)
|
||||||
|
// This is initialized at program startup before any threads
|
||||||
|
namespace {
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||||
|
DefaultHeaders default_headers_instance;
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
DefaultHeaders &DefaultHeaders::Instance() { return default_headers_instance; }
|
||||||
|
|
||||||
void AsyncWebServer::end() {
|
void AsyncWebServer::end() {
|
||||||
if (this->server_) {
|
if (this->server_) {
|
||||||
httpd_stop(this->server_);
|
httpd_stop(this->server_);
|
||||||
|
@ -328,10 +328,7 @@ class DefaultHeaders {
|
|||||||
void addHeader(const char *name, const char *value) { this->headers_.emplace_back(name, value); }
|
void addHeader(const char *name, const char *value) { this->headers_.emplace_back(name, value); }
|
||||||
|
|
||||||
// NOLINTNEXTLINE(readability-identifier-naming)
|
// NOLINTNEXTLINE(readability-identifier-naming)
|
||||||
static DefaultHeaders &Instance() {
|
static DefaultHeaders &Instance();
|
||||||
static DefaultHeaders instance;
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<std::pair<std::string, std::string>> headers_;
|
std::vector<std::pair<std::string, std::string>> headers_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user