Remove unnecessary boxing of Stack::recursion_count (#11238)

This commit is contained in:
Ian Manske 2023-12-06 08:48:56 +00:00 committed by GitHub
parent 858c93d2e5
commit 51bf8d9f6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View file

@ -611,14 +611,14 @@ pub fn eval_block(
// picked 50 arbitrarily, should work on all architectures
const RECURSION_LIMIT: u64 = 50;
if recursive {
if *stack.recursion_count >= RECURSION_LIMIT {
stack.recursion_count = Box::new(0);
if stack.recursion_count >= RECURSION_LIMIT {
stack.recursion_count = 0;
return Err(ShellError::RecursionLimitReached {
recursion_limit: RECURSION_LIMIT,
span: block.span,
});
}
*stack.recursion_count += 1;
stack.recursion_count += 1;
}
}

View file

@ -35,7 +35,7 @@ pub struct Stack {
pub env_hidden: HashMap<String, HashSet<String>>,
/// List of active overlays
pub active_overlays: Vec<String>,
pub recursion_count: Box<u64>,
pub recursion_count: u64,
}
impl Stack {
@ -45,7 +45,7 @@ impl Stack {
env_vars: vec![],
env_hidden: HashMap::new(),
active_overlays: vec![DEFAULT_OVERLAY_NAME.to_string()],
recursion_count: Box::new(0),
recursion_count: 0,
}
}
@ -159,7 +159,7 @@ impl Stack {
env_vars,
env_hidden: self.env_hidden.clone(),
active_overlays: self.active_overlays.clone(),
recursion_count: self.recursion_count.to_owned(),
recursion_count: self.recursion_count,
}
}
@ -186,7 +186,7 @@ impl Stack {
env_vars,
env_hidden: self.env_hidden.clone(),
active_overlays: self.active_overlays.clone(),
recursion_count: self.recursion_count.to_owned(),
recursion_count: self.recursion_count,
}
}