Skip to content

Optimize PathBuf usage in handle_build to avoid unnecessary clone #88

@coderabbitai

Description

@coderabbitai

Description

In src/runner.rs, the handle_build function performs an unnecessary PathBuf clone when handling the emitted path (line 118):

(path.clone(), None)

Optimization Opportunity

The tuple type (PathBuf, Option<NamedTempFile>) could be replaced with (Cow<Path>, Option<NamedTempFile>) to avoid the allocation when borrowing the emitted path. The Some(path) branch would borrow the path without cloning, while the temp-file branch would own the path.

Context

This optimization was identified during the review of PR #82 and discussed in this comment thread.

Issue: #88

Requested by

@leynos

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions