Skip to content

Conversation

@XmchxUp
Copy link
Contributor

@XmchxUp XmchxUp commented Sep 10, 2025

Closes: #1846

@mre
Copy link
Member

mre commented Sep 23, 2025

Thanks for the PR. It's been a while since I found the time to review it. Looks good overall.

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(),
};
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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.

@XmchxUp XmchxUp changed the title refactor: Remove truncate_source and inline string truncation logic refactor: Remove truncate_source logic Sep 24, 2025
@mre mre merged commit 8222559 into lycheeverse:master Sep 24, 2025
6 checks passed
@mre
Copy link
Member

mre commented Sep 24, 2025

Thanks a lot @XmchxUp! ✌️

@mre mre mentioned this pull request Sep 18, 2025
This was referenced Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

See if truncate_source can be removed

2 participants