This commit is contained in:
Stephen Chung 2022-07-20 21:06:36 +08:00
parent 2ac6336173
commit ff6a448b77
3 changed files with 6 additions and 9 deletions

View File

@ -156,13 +156,11 @@ impl GlobalRuntimeState<'_> {
pub fn find_import(&self, name: &str) -> Option<usize> { pub fn find_import(&self, name: &str) -> Option<usize> {
let len = self.keys.len(); let len = self.keys.len();
self.keys.iter().rev().enumerate().find_map(|(i, key)| { self.keys
if key == name { .iter()
Some(len - 1 - i) .rev()
} else { .position(|key| key == name)
None .map(|i| len - 1 - i)
}
})
} }
/// Push an imported [module][crate::Module] onto the stack. /// Push an imported [module][crate::Module] onto the stack.
/// ///

View File

@ -720,7 +720,7 @@ fn optimize_stmt(stmt: &mut Stmt, state: &mut OptimizerState, preserve_result: b
// Remove all entries after a `true` condition // Remove all entries after a `true` condition
if let Some(n) = list if let Some(n) = list
.iter() .iter()
.find(|&&index| expressions[index].is_always_true()) .position(|&index| expressions[index].is_always_true())
{ {
if n + 1 < list.len() { if n + 1 < list.len() {
state.set_dirty(); state.set_dirty();

View File

@ -186,7 +186,6 @@ pub enum Union {
TimeStamp(Box<Instant>, Tag, AccessMode), TimeStamp(Box<Instant>, Tag, AccessMode),
/// Any type as a trait object. /// Any type as a trait object.
#[allow(clippy::redundant_allocation)]
Variant(Box<Box<dyn Variant>>, Tag, AccessMode), Variant(Box<Box<dyn Variant>>, Tag, AccessMode),
/// A _shared_ value of any type. /// A _shared_ value of any type.