General code improvements

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
Lee Smet
2025-08-22 12:48:36 +02:00
parent 74995fa6fe
commit bc6cb16732
4 changed files with 32 additions and 19 deletions

View File

@@ -94,14 +94,14 @@ pub async fn build_flow_dag(
.await
.map_err(DagError::from)?;
let caller_id = flow.caller_id();
let flow_job_ids = flow.jobs().clone();
let flow_job_ids = flow.jobs();
// Build a set for faster membership tests
let job_id_set: HashSet<u32> = flow_job_ids.iter().copied().collect();
// Load all jobs
let mut jobs: HashMap<u32, Job> = HashMap::with_capacity(flow_job_ids.len());
for jid in &flow_job_ids {
for jid in flow_job_ids {
let job = redis
.load_job(context_id, caller_id, *jid)
.await
@@ -116,7 +116,7 @@ pub async fn build_flow_dag(
let mut rev_adj: HashMap<u32, Vec<u32>> = HashMap::with_capacity(jobs.len());
let mut in_degree: HashMap<u32, usize> = HashMap::with_capacity(jobs.len());
for &jid in &flow_job_ids {
for &jid in flow_job_ids {
adj.entry(jid).or_default();
rev_adj.entry(jid).or_default();
in_degree.entry(jid).or_insert(0);