diff options
| author | metamuffin <metamuffin@disroot.org> | 2026-01-06 23:43:05 +0100 |
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2026-01-06 23:43:05 +0100 |
| commit | f932d4de439c6472d34ed4bbf530fca13b84d73a (patch) | |
| tree | b64f28fc6bdf40a38ed6e08cc7ce4602d3a4c537 /common/object/src/buffer.rs | |
| parent | ffa6b5c4ae2cdd3e07426ed0330f3f66e90ee57b (diff) | |
| download | jellything-f932d4de439c6472d34ed4bbf530fca13b84d73a.tar jellything-f932d4de439c6472d34ed4bbf530fca13b84d73a.tar.bz2 jellything-f932d4de439c6472d34ed4bbf530fca13b84d73a.tar.zst | |
object insert
Diffstat (limited to 'common/object/src/buffer.rs')
| -rw-r--r-- | common/object/src/buffer.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/common/object/src/buffer.rs b/common/object/src/buffer.rs index dbde833..2f9d066 100644 --- a/common/object/src/buffer.rs +++ b/common/object/src/buffer.rs @@ -24,8 +24,9 @@ impl ObjectBuffer { let mut temp = Vec::new(); for (tag, val) in fields { tags.push(tag.0); + let off = (values.len() as u32) << 2; if val.is_aligned() { - offsets.push((values.len() as u32) << 2); + offsets.push(off); val.store_aligned(&mut values); } else { temp.clear(); @@ -35,7 +36,7 @@ impl ObjectBuffer { pad += 1; temp.push(0); } - offsets.push(((values.len() as u32) << 2) | pad); + offsets.push(off | pad); values.extend(bytemuck::cast_slice(&temp)); // ok bc. temp length is a whole number of dwords } } @@ -60,3 +61,13 @@ impl From<Vec<u8>> for ObjectBuffer { })) } } + +#[inline] +pub(super) fn pad_vec(temp: &mut Vec<u8>) -> u32 { + let mut pad = 0; + while temp.len() % 4 != 0 { + pad += 1; + temp.push(0); + } + pad +} |