aboutsummaryrefslogtreecommitdiff
path: root/common/object/src/value.rs
diff options
context:
space:
mode:
Diffstat (limited to 'common/object/src/value.rs')
-rw-r--r--common/object/src/value.rs13
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