[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:
J. Nick Koston 2025-08-03 16:00:56 -10:00 committed by GitHub
parent cd6cf074d9
commit 3fbbdb4589
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -423,15 +423,15 @@ 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_() {
while (!deferred_queue_.empty()) {