Refactor optimizer utilities

Removes unused `flatten_tuple` function from optimizer utilities. The
functionality was moved to the `Folder` struct, making it more
contextually appropriate. This change streamlines the utility module and
improves code organization.
This commit is contained in:
Michael Schimmel
2026-02-25 21:26:12 +01:00
parent cf87bbeac5
commit 81c805f07e
6 changed files with 456 additions and 460 deletions
+3 -6
View File
@@ -6,7 +6,7 @@ use std::collections::{HashMap, HashSet};
use std::rc::Rc;
use super::substitution_map::SubstitutionMap;
use super::utils::{flatten_tuple, UsageInfo};
use super::utils::UsageInfo;
pub struct Inliner<'a> {
pub globals: &'a Option<Rc<RefCell<Vec<Value>>>>,
@@ -64,18 +64,15 @@ impl<'a> Inliner<'a> {
pub fn prepare_beta_reduction(
&self,
params: &AnalyzedNode,
args: &AnalyzedNode,
arg_vals: &[AnalyzedNode],
body: &AnalyzedNode,
sub: &mut SubstitutionMap,
) -> Option<()> {
let mut body_usage = UsageInfo::default();
body_usage.collect(body);
let mut arg_vals = Vec::new();
flatten_tuple(args.clone(), &mut arg_vals);
let mut slot_index = 0;
self.map_params_to_args(params, &arg_vals, &mut slot_index, sub, &body_usage);
self.map_params_to_args(params, arg_vals, &mut slot_index, sub, &body_usage);
if slot_index != arg_vals.len() {
return None;