Skip to content

Commit

Permalink
[experiment] revert const eval trick in vec
Browse files Browse the repository at this point in the history
  • Loading branch information
the8472 committed May 8, 2024
1 parent c3202af commit 5e5deaa
Showing 1 changed file with 6 additions and 13 deletions.
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

0 comments on commit 5e5deaa

Please sign in to comment.