Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/brioche-core/src/bake/attach_resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ pub async fn attach_resources(brioche: &Brioche, directory: &mut Directory) -> a
.graph
.edges_directed(node_index, petgraph::Direction::Outgoing);

for edge in edges_out {
let AttachResourcesPlanEdge::InternalResource(resource) = &edge.weight();
resources_to_attach.push(resource);
}
resources_to_attach.extend(edges_out.map(|edge| {
let AttachResourcesPlanEdge::InternalResource(resource) = edge.weight();
resource
}));
}

// If there are no resources to attach, no need to update this node
Expand Down
19 changes: 8 additions & 11 deletions crates/brioche-core/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,11 +564,10 @@ impl ProjectsInner {
&self,
project_hashes: &HashSet<ProjectHash>,
) -> anyhow::Result<impl Iterator<Item = PathBuf>> {
let mut paths = Vec::with_capacity(project_hashes.len());
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally the code should preallocate the vector on collect correctly, by doing a size_of() on project_hashes.

for project_hash in project_hashes {
paths.push(self.project_module_paths(*project_hash)?);
}

let paths = project_hashes
.iter()
.map(|project_hash| self.project_module_paths(*project_hash))
.collect::<Result<Vec<_>, _>>()?;
Ok(paths.into_iter().flatten())
}

Expand Down Expand Up @@ -600,12 +599,10 @@ impl ProjectsInner {
project_hashes: &HashSet<ProjectHash>,
) -> anyhow::Result<impl Iterator<Item = super::script::specifier::BriocheModuleSpecifier>>
{
let mut module_specifiers = Vec::with_capacity(project_hashes.len());
for project_hash in project_hashes {
let module_paths = self.project_module_specifiers(*project_hash)?;
module_specifiers.push(module_paths);
}

let module_specifiers = project_hashes
.iter()
.map(|project_hash| self.project_module_specifiers(*project_hash))
.collect::<Result<Vec<_>, _>>()?;
Ok(module_specifiers.into_iter().flatten())
}

Expand Down
8 changes: 4 additions & 4 deletions crates/brioche-core/src/project/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,12 @@ async fn load_project_inner(
dependencies
.insert(dep_name.clone(), DependencyRef::Project(*dep_project_hash));

for error in &dep_errors[..] {
errors.push(LoadProjectError::DependencyError {
errors.extend(dep_errors.iter().map(|error| {
LoadProjectError::DependencyError {
name: dep_name.clone(),
error: Box::new(error.clone()),
});
}
}
}));
}
}

Expand Down