Open
Description
Box<[T]>
requires 2x assembly (96 -> 185) compared to Vec<T>
. I think this could be improved.
pub fn t<'a>(iter: &'a [&str]) -> Vec<&'a str> {
iter.iter().cloned().collect()
}
pub fn t<'a>(iter: &'a [&str]) -> Box<[&'a str]> {
iter.iter().cloned().collect()
}
Looking at the generated code, looks like some extra unnecessary checks were added.
hmm, some panic handling for "Tried to shrink to a larger capacity"
(which should be statically unreachable)
Is that even possible?
no, but I guess it isn't seeing that len<=capacity
@cuviper
However, this does not affect the following.
pub fn t<'a>() -> Box<[&'a str]> {
["a", "b"].iter().cloned().collect()
}
I will be taking a look at this in the meantime while looking at join
for Iterator
. I wish an assert
could solve this.
Metadata
Metadata
Assignees
Labels
Area: `std::collections`Area: IteratorsCategory: An issue highlighting optimization opportunities or PRs implementing suchCall for participation: Help is requested to fix this issue.Call for participation: Medium difficulty. Experience needed to fix: Intermediate.Issue: Problems and improvements with respect to binary size of generated code.Relevant to the library team, which will review and decide on the PR/issue.