diff options
| author | metamuffin <metamuffin@disroot.org> | 2026-02-17 15:29:47 +0100 |
|---|---|---|
| committer | metamuffin <metamuffin@disroot.org> | 2026-02-17 15:29:47 +0100 |
| commit | e9c95c663728b0d7b4a73cbc4cd355578d0f7d9e (patch) | |
| tree | f18d4b805dcebe2e0172dc05d3089cfa3acf50a7 /common/object | |
| parent | 92d544b140894944fa5d8c7dca272d032f7717a7 (diff) | |
| download | jellything-e9c95c663728b0d7b4a73cbc4cd355578d0f7d9e.tar jellything-e9c95c663728b0d7b4a73cbc4cd355578d0f7d9e.tar.bz2 jellything-e9c95c663728b0d7b4a73cbc4cd355578d0f7d9e.tar.zst | |
fix f64 object store
Diffstat (limited to 'common/object')
| -rw-r--r-- | common/object/src/value.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/common/object/src/value.rs b/common/object/src/value.rs index 817ccdc..086f2fd 100644 --- a/common/object/src/value.rs +++ b/common/object/src/value.rs @@ -97,7 +97,14 @@ impl ValueStore for u64 { impl Value<'_> for f64 { const ALIGNED: bool = true; fn load_aligned(buf: &[u32]) -> Option<Self> { - u32::load_aligned(buf).map(|x| x as f64) + if buf.len() < 2 { + return None; + }; + let a = u32::to_be_bytes(buf[0]); + let b = u32::to_be_bytes(buf[1]); + Some(f64::from_be_bytes([ + a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3], + ])) } } impl ValueStore for f64 { @@ -105,7 +112,9 @@ impl ValueStore for f64 { true } fn store_aligned(&self, buf: &mut Vec<u32>) { - (*self as u64).store_aligned(buf); + let b = self.to_be_bytes(); + buf.push(u32::from_be_bytes([b[0], b[1], b[2], b[3]])); + buf.push(u32::from_be_bytes([b[4], b[5], b[6], b[7]])); } fn size(&self) -> usize { 8 |