Add iter() and values() functions to PrimaryMap and EntityMap.
`iter()` iterates over both keys and values, while `values()` iterates over just values. Also add `_mut()` versions. These replace the otherwise common idiom of iterating with `keys()` and using indexing to get the values, allowing for simpler code.
This commit is contained in:
@@ -39,9 +39,7 @@ pub fn layout_stack(frame: &mut StackSlots, alignment: StackSize) -> Result<Stac
|
||||
let mut outgoing_max = 0;
|
||||
let mut min_align = alignment;
|
||||
|
||||
for ss in frame.keys() {
|
||||
let slot = &frame[ss];
|
||||
|
||||
for slot in frame.values() {
|
||||
if slot.size > max_size {
|
||||
return Err(CtonError::ImplLimitExceeded);
|
||||
}
|
||||
@@ -72,9 +70,7 @@ pub fn layout_stack(frame: &mut StackSlots, alignment: StackSize) -> Result<Stac
|
||||
let mut offset = incoming_min;
|
||||
debug_assert!(min_align.is_power_of_two());
|
||||
while min_align <= alignment {
|
||||
for ss in frame.keys() {
|
||||
let slot = frame[ss].clone();
|
||||
|
||||
for slot in frame.values_mut() {
|
||||
// Pick out explicit and spill slots with exact alignment `min_align`.
|
||||
match slot.kind {
|
||||
StackSlotKind::SpillSlot |
|
||||
@@ -94,7 +90,7 @@ pub fn layout_stack(frame: &mut StackSlots, alignment: StackSize) -> Result<Stac
|
||||
|
||||
// Aligning the negative offset can never cause overflow. We're only clearing bits.
|
||||
offset &= -(min_align as StackOffset);
|
||||
frame.set_offset(ss, offset);
|
||||
slot.offset = Some(offset);
|
||||
}
|
||||
|
||||
// Move on to the next higher alignment.
|
||||
|
||||
Reference in New Issue
Block a user