Skip to content

Commit 9f9e508

Browse files
Rollup merge of #157130 - alexcrichton:refactor-cast-target-internals, r=nnethercote
Use a `ArrayVec` in `CastTarget` This commit switches a fixed-size list of `[Option<Reg>; 8]` to instead holding `ArrayVec<Reg, 8>` in the `CastTarget` type used when calculating ABIs. This is inspired by [discussion on Zulip][link] where I'm hoping to in the near future extend the usage of this to possibly beyond 8 elements for a new WebAssembly ABI taking advantage of multi-value. For now though this mostly just switches to array/slice-like idioms of accessors rather than dealing with `Option<Reg>` as the unit. [link]: https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Using.20.60ArgAbi.3A.3Amake_direct_deprecated.60/with/598607139
2 parents 418adda + c3101c0 commit 9f9e508

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/abi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl GccType for CastTarget {
4646
)
4747
};
4848

49-
if self.prefix.iter().all(|x| x.is_none()) {
49+
if self.prefix.is_empty() {
5050
// Simplify to a single unit when there is no prefix and size <= unit size
5151
if self.rest.total <= self.rest.unit.size {
5252
return rest_gcc_unit;
@@ -62,7 +62,7 @@ impl GccType for CastTarget {
6262
let mut args: Vec<_> = self
6363
.prefix
6464
.iter()
65-
.flat_map(|option_reg| option_reg.map(|reg| reg.gcc_type(cx)))
65+
.map(|reg| reg.gcc_type(cx))
6666
.chain((0..rest_count).map(|_| rest_gcc_unit))
6767
.collect();
6868

0 commit comments

Comments
 (0)