mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	Eliminate web_server_idf guard variable to save 8 bytes RAM
This commit is contained in:
		| @@ -37,6 +37,12 @@ namespace 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 | ||||
| static DefaultHeaders default_headers_instance; | ||||
|  | ||||
| DefaultHeaders &DefaultHeaders::Instance() { return default_headers_instance; } | ||||
|  | ||||
| void AsyncWebServer::end() { | ||||
|   if (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); } | ||||
|  | ||||
|   // NOLINTNEXTLINE(readability-identifier-naming) | ||||
|   static DefaultHeaders &Instance() { | ||||
|     static DefaultHeaders instance; | ||||
|     return instance; | ||||
|   } | ||||
|   static DefaultHeaders &Instance(); | ||||
|  | ||||
|  protected: | ||||
|   std::vector<std::pair<std::string, std::string>> headers_; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user