mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 15:12:06 +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) { | void AsyncEventSourceResponse::deq_push_back_with_dedup_(void *source, message_generator_t *message_generator) { | ||||||
|   DeferredEvent item(source, message_generator); |   DeferredEvent item(source, message_generator); | ||||||
|  |  | ||||||
|   auto iter = std::find_if(this->deferred_queue_.begin(), this->deferred_queue_.end(), |   // Use range-based for loop instead of std::find_if to reduce template instantiation overhead and binary size | ||||||
|                            [&item](const DeferredEvent &test) -> bool { return test == item; }); |   for (auto &event : this->deferred_queue_) { | ||||||
|  |     if (event == item) { | ||||||
|   if (iter != this->deferred_queue_.end()) { |       event = item; | ||||||
|     (*iter) = item; |       return; | ||||||
|   } else { |  | ||||||
|     this->deferred_queue_.push_back(item); |  | ||||||
|     } |     } | ||||||
|  |   } | ||||||
|  |   this->deferred_queue_.push_back(item); | ||||||
| } | } | ||||||
|  |  | ||||||
| void AsyncEventSourceResponse::process_deferred_queue_() { | void AsyncEventSourceResponse::process_deferred_queue_() { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user