Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer pop_first if it is available #3084

Merged
merged 1 commit into from Jan 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/yew/src/scheduler.rs
Expand Up @@ -46,12 +46,20 @@ impl TopologicalQueue {
}

/// Take a single entry, preferring parents over children
#[rustversion::before(1.66)]
fn pop_topmost(&mut self) -> Option<QueueEntry> {
// To be replaced with BTreeMap::pop_first once it is stable.
// BTreeMap::pop_first is available after 1.66.
let key = *self.inner.keys().next()?;
self.inner.remove(&key)
}

/// Take a single entry, preferring parents over children
#[rustversion::since(1.66)]
#[inline]
fn pop_topmost(&mut self) -> Option<QueueEntry> {
self.inner.pop_first().map(|(_, v)| v)
}

/// Drain all entries, such that children are queued before parents
fn drain_post_order_into(&mut self, queue: &mut Vec<QueueEntry>) {
if self.inner.is_empty() {
Expand Down