mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
short-circuit loading field from size 0 struct
This commit is contained in:
parent
37eec2b7c2
commit
29bc9a2e85
1 changed files with 10 additions and 2 deletions
|
@ -542,13 +542,21 @@ impl<
|
||||||
field_layouts: &'a [InLayout<'a>],
|
field_layouts: &'a [InLayout<'a>],
|
||||||
) {
|
) {
|
||||||
debug_assert!(index < field_layouts.len() as u64);
|
debug_assert!(index < field_layouts.len() as u64);
|
||||||
|
|
||||||
|
let storage = *self.get_storage_for_sym(structure);
|
||||||
|
|
||||||
|
if let NoData = storage {
|
||||||
|
return self.no_data(sym);
|
||||||
|
}
|
||||||
|
|
||||||
// This must be removed and reinserted for ownership and mutability reasons.
|
// This must be removed and reinserted for ownership and mutability reasons.
|
||||||
let owned_data = self.remove_allocation_for_sym(structure);
|
let owned_data = self.remove_allocation_for_sym(structure);
|
||||||
self.allocation_map
|
self.allocation_map
|
||||||
.insert(*structure, Rc::clone(&owned_data));
|
.insert(*structure, Rc::clone(&owned_data));
|
||||||
match self.get_storage_for_sym(structure) {
|
|
||||||
|
match storage {
|
||||||
Stack(Complex { base_offset, size }) => {
|
Stack(Complex { base_offset, size }) => {
|
||||||
let (base_offset, size) = (*base_offset, *size);
|
let (base_offset, size) = (base_offset, size);
|
||||||
let mut data_offset = base_offset;
|
let mut data_offset = base_offset;
|
||||||
for layout in field_layouts.iter().take(index as usize) {
|
for layout in field_layouts.iter().take(index as usize) {
|
||||||
let field_size = layout_interner.stack_size(*layout);
|
let field_size = layout_interner.stack_size(*layout);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue