Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[perf] experiment, revert cost optimization in vec code #124907

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions library/alloc/src/vec/in_place_collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,19 +230,12 @@ where
<I as SourceIter>::Source: AsVecIntoIter,
{
default fn from_iter(iterator: I) -> Self {
// Select the implementation in const eval to avoid codegen of the dead branch to improve compile times.
let fun: fn(I) -> Vec<T> = const {
// See "Layout constraints" section in the module documentation. We use const conditions here
// since these conditions currently cannot be expressed as trait bounds
if in_place_collectible::<T, I::Src>(I::MERGE_BY, I::EXPAND_BY) {
from_iter_in_place
} else {
// fallback
SpecFromIterNested::<T, I>::from_iter
}
};

fun(iterator)
if const { in_place_collectible::<T, I::Src>(I::MERGE_BY, I::EXPAND_BY) } {
from_iter_in_place(iterator)
} else {
// fallback
SpecFromIterNested::<T, I>::from_iter(iterator)
}
}
}

Expand Down
Loading