ref: Use slice instead of vec for assemble artifact request#2498
Merged
szokeasaurusrex merged 1 commit intomasterfrom May 8, 2025
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR updates the way projects are passed to the assemble artifact request by replacing allocations via Vec with slice references. The changes affect three files to reduce unnecessary allocations when constructing the projects list.
- Changed file_upload.rs to use slice literals instead of vectors when calling the API.
- Updated src/api/mod.rs to accept slice parameters and pass empty slice literals.
- Modified the ChunkedArtifactRequest in src/api/data_types/chunking/artifact.rs to hold a slice reference instead of a Vec.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/utils/file_upload.rs | Replaced vector construction with slice literal for the projects parameter |
| src/api/mod.rs | Adjusted the API method signature and usage to accept a slice, including empty slice usage |
| src/api/data_types/chunking/artifact.rs | Updated the projects field type and its serializer condition for slice references |
Comments suppressed due to low confidence (3)
src/utils/file_upload.rs:461
- Using a slice literal instead of a vector reduces heap allocations. Ensure that the temporary String created by to_string() has a suitable lifetime for the API call.
+ &[context.project.unwrap().to_string()],
src/api/mod.rs:999
- Switching to an empty slice literal improves efficiency by avoiding unnecessary vector construction. Verify that the changes align with the expected lifetime requirements of the API.
+ projects: &[],
src/api/data_types/chunking/artifact.rs:10
- Updating the skip_serializing_if condition to use the slice pattern is appropriate for the new type change. Confirm that this serializer condition correctly handles empty slices.
+ #[serde(skip_serializing_if = "<[_]>::is_empty")]
loewenheim
approved these changes
May 8, 2025
813fa81 to
8a63fec
Compare
1bb1afc to
f540dc1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split off from #2408