Skip to content

Commit 1d626bd

Browse files
committed
Make better use of struct aligns
1 parent 10059e0 commit 1d626bd

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/number.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ const NAN_MASK: u8 = !1;
1616
#[derive(Copy, Clone, Debug)]
1717
pub struct Number {
1818
category: u8,
19-
mantissa: u64,
2019
exponent: i16,
20+
mantissa: u64,
2121
}
2222

2323
impl Number {
2424
#[inline]
2525
pub fn from_parts(positive: bool, mantissa: u64, exponent: i16) -> Self {
2626
Number {
2727
category: positive as u8,
28-
mantissa: mantissa,
2928
exponent: exponent,
29+
mantissa: mantissa,
3030
}
3131
}
3232

@@ -249,8 +249,8 @@ macro_rules! impl_unsigned {
249249
fn from(num: $t) -> Number {
250250
Number {
251251
category: POSITIVE,
252-
mantissa: num as u64,
253252
exponent: 0,
253+
mantissa: num as u64,
254254
}
255255
}
256256
}
@@ -267,14 +267,14 @@ macro_rules! impl_signed {
267267
if num < 0 {
268268
Number {
269269
category: NEGATIVE,
270-
mantissa: -num as u64,
271270
exponent: 0,
271+
mantissa: -num as u64,
272272
}
273273
} else {
274274
Number {
275275
category: POSITIVE,
276-
mantissa: num as u64,
277276
exponent: 0,
277+
mantissa: num as u64,
278278
}
279279
}
280280
}
@@ -332,8 +332,8 @@ impl ops::Neg for Number {
332332
fn neg(self) -> Number {
333333
Number {
334334
category: self.category ^ POSITIVE,
335-
mantissa: self.mantissa,
336335
exponent: self.exponent,
336+
mantissa: self.mantissa,
337337
}
338338
}
339339
}
@@ -354,8 +354,8 @@ impl ops::Mul for Number {
354354
// Xor all the things! ^ _ ^
355355

356356
category: self.category ^ other.category ^ POSITIVE,
357-
mantissa: self.mantissa * other.mantissa,
358357
exponent: self.exponent + other.exponent,
358+
mantissa: self.mantissa * other.mantissa,
359359
}
360360
}
361361
}

src/object.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::{ ptr, mem, str, slice, fmt };
22

33
use value::JsonValue;
44

5-
const KEY_BUF_LEN: usize = 30;
5+
const KEY_BUF_LEN: usize = 32;
66

77
struct Node {
88
// Internal buffer to store keys that fit within `KEY_BUF_LEN`,

src/short.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ pub const MAX_LEN: usize = 30;
55

66
#[derive(Clone, Copy)]
77
pub struct Short {
8-
value: [u8; MAX_LEN],
98
len: u8,
9+
value: [u8; MAX_LEN],
1010
}
1111

1212
/// A `Short` is a small string, up to `MAX_LEN` bytes, that can be managed without

0 commit comments

Comments
 (0)