mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	[web_server_idf] Replace std::find_if with simple loop to reduce binary size (#10042)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
		| @@ -423,14 +423,14 @@ void AsyncEventSourceResponse::destroy(void *ptr) { | ||||
| void AsyncEventSourceResponse::deq_push_back_with_dedup_(void *source, message_generator_t *message_generator) { | ||||
|   DeferredEvent item(source, message_generator); | ||||
|  | ||||
|   auto iter = std::find_if(this->deferred_queue_.begin(), this->deferred_queue_.end(), | ||||
|                            [&item](const DeferredEvent &test) -> bool { return test == item; }); | ||||
|  | ||||
|   if (iter != this->deferred_queue_.end()) { | ||||
|     (*iter) = item; | ||||
|   } else { | ||||
|     this->deferred_queue_.push_back(item); | ||||
|   // Use range-based for loop instead of std::find_if to reduce template instantiation overhead and binary size | ||||
|   for (auto &event : this->deferred_queue_) { | ||||
|     if (event == item) { | ||||
|       event = item; | ||||
|       return; | ||||
|     } | ||||
|   } | ||||
|   this->deferred_queue_.push_back(item); | ||||
| } | ||||
|  | ||||
| void AsyncEventSourceResponse::process_deferred_queue_() { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user