refactor: Remove truncate_source logic#1847
Merged
mre merged 1 commit intolycheeverse:masterfrom Sep 24, 2025
Merged
Conversation
Member
|
Thanks for the PR. It's been a while since I found the time to review it. Looks good overall. |
mre
reviewed
Sep 23, 2025
lychee-lib/src/utils/request.rs
Outdated
Comment on lines
35
to
49
| let source = match source { | ||
| ResolvedInputSource::String(s) => { | ||
| if s.len() <= MAX_TRUNCATED_STR_LEN { | ||
| match s { | ||
| Cow::Borrowed(s_ref) => ResolvedInputSource::String(Cow::Borrowed(s_ref)), | ||
| Cow::Owned(s_owned) => ResolvedInputSource::String(Cow::Owned(s_owned.clone())), | ||
| } | ||
| } else { | ||
| ResolvedInputSource::String(Cow::Owned( | ||
| s.chars().take(MAX_TRUNCATED_STR_LEN).collect(), | ||
| )) | ||
| } | ||
| } | ||
| other => other.clone(), | ||
| }; |
Member
There was a problem hiding this comment.
Do we even need to truncate the input at all? If so, should we add a comment why this is still needed? I did not run any benchmarks, but my thinking was that we wanted to avoid expensive clones in the past, but with Cow it shouldn't be a problem anymore.
Contributor
Author
There was a problem hiding this comment.
You’re right — with Cow we no longer need to worry about expensive clones. I can’t think of any other reason for keeping the truncate_source logic, so I’d suggest removing it altogether.
d0dcb71 to
d9dacbc
Compare
Member
|
Thanks a lot @XmchxUp! ✌️ |
Closed
This was referenced Oct 21, 2025
Closed
Merged
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.
Closes: #1846