diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs index d291eaba747..16efff8d5b7 100644 --- a/components/script/dom/eventtarget.rs +++ b/components/script/dom/eventtarget.rs @@ -448,7 +448,7 @@ impl EventTarget { let listener = EventListenerType::Additive(listener.clone()); if let Some(entries) = handlers.get_mut(ty) { - entries.drain_filter(|e| e.listener == listener && e.once); + entries.retain(|e| e.listener != listener || !e.once) } } diff --git a/components/script/lib.rs b/components/script/lib.rs index be61094d1da..0e652d0be5b 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -#![feature(drain_filter)] #![feature(once_cell)] #![feature(plugin)] #![feature(register_tool)] diff --git a/components/script/task_queue.rs b/components/script/task_queue.rs index 38acc7ed04b..bb58dea8ab1 100644 --- a/components/script/task_queue.rs +++ b/components/script/task_queue.rs @@ -120,23 +120,29 @@ impl TaskQueue { } // 4. Filter tasks from non-priority task-sources. - let to_be_throttled: Vec = incoming - .drain_filter(|msg| { - let task_source = match msg.task_source_name() { - Some(task_source) => task_source, - None => return false, - }; - match task_source { - TaskSourceName::PerformanceTimeline => return true, - _ => { - // A task that will not be throttled, start counting "business" - self.taken_task_counter - .set(self.taken_task_counter.get() + 1); - return false; - }, - } - }) - .collect(); + // TODO: This can use `extract_if` once that is stabilized. + let mut to_be_throttled = Vec::new(); + let mut index = 0; + while index != incoming.len() { + index += 1; // By default we go to the next index of the vector. + + let task_source = match incoming[index - 1].task_source_name() { + Some(task_source) => task_source, + None => continue, + }; + + match task_source { + TaskSourceName::PerformanceTimeline => { + to_be_throttled.push(incoming.remove(index - 1)); + index -= 1; // We've removed an element, so the next has the same index. + }, + _ => { + // A task that will not be throttled, start counting "business" + self.taken_task_counter + .set(self.taken_task_counter.get() + 1); + }, + } + } for msg in incoming { if let Some(pipeline_id) = msg.pipeline_id() {