aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/task_queue.rs
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2023-11-17 11:28:33 +0100
committerGitHub <noreply@github.com>2023-11-17 10:28:33 +0000
commit8de4629a3c769e78c47a163326f045ca53ed6298 (patch)
treee34206d65b450047f1ae5a41f334a1ddcd031d1a /components/script/task_queue.rs
parent50732b49c5ad3937cf2b8f94e86a9efa1f2ce4de (diff)
downloadservo-8de4629a3c769e78c47a163326f045ca53ed6298.tar.gz
servo-8de4629a3c769e78c47a163326f045ca53ed6298.zip
Remove usage of `drain_filter` (#30742)
This is a step on the way toward supporting stable rust.
Diffstat (limited to 'components/script/task_queue.rs')
-rw-r--r--components/script/task_queue.rs40
1 files changed, 23 insertions, 17 deletions
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<T: QueuedTaskConversion> TaskQueue<T> {
}
// 4. Filter tasks from non-priority task-sources.
- let to_be_throttled: Vec<T> = 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() {