Auto merge of #88242 - bonega:allocation_range, r=oli-obk
Use custom wrap-around type instead of RangeInclusive Two reasons: 1. More memory is allocated than necessary for `valid_range` in `Scalar`. The range is not used as an iterator and `exhausted` is never used. 2. `contains`, `count` etc. methods in `RangeInclusive` are doing very unhelpful(and dangerous!) things when used as a wrap-around range. - In general this PR wants to limit potentially confusing methods, that have a low probability of working. Doing a local perf run, every metric shows improvement except for instructions. Max-rss seem to have a very consistent improvement. Sorry - newbie here, probably doing something wrong.
This commit is contained in:
commit
e5484cec0e
8 changed files with 115 additions and 81 deletions
|
@ -795,7 +795,7 @@ crate fn repr_nullable_ptr<'tcx>(
|
|||
// Return the nullable type this Option-like enum can be safely represented with.
|
||||
let field_ty_abi = &cx.layout_of(field_ty).unwrap().abi;
|
||||
if let Abi::Scalar(field_ty_scalar) = field_ty_abi {
|
||||
match (field_ty_scalar.valid_range.start(), field_ty_scalar.valid_range.end()) {
|
||||
match (field_ty_scalar.valid_range.start, field_ty_scalar.valid_range.end) {
|
||||
(0, _) => unreachable!("Non-null optimisation extended to a non-zero value."),
|
||||
(1, _) => {
|
||||
return Some(get_nullable_type(cx, field_ty).unwrap());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue