You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add missing #[inline] attributes for f32 and f64 in primitive.rs
I testing this change on the following simple program:
```
pub mod primlist_capnp {
include!(concat!(env!("OUT_DIR"), "/primlist_capnp.rs"));
}
pub fn main() {
let mut scratch_space = vec![0u8; 16000];
let mut input: Vec<f64>= vec![0.0;1500];
let mut cc = 1.1;
for _ in 0 .. 500000 {
for inp in &mut input[..] {
*inp = cc;
cc += 0.02;
}
cc -= input.len() as f64 * 0.02;
cc += 0.001;
let allocator = capnp::message::ScratchSpaceHeapAllocator::new(&mut scratch_space);
let mut message = ::capnp::message::Builder::new(allocator);
let root : primlist_capnp::foo::Builder = message.init_root();
let mut list = root.init_float_list(input.len() as u32);
for (i,n) in input.iter().enumerate() {
list.set(i as u32,*n);
}
for (i,n) in input.iter().enumerate() {
assert_eq!(*n, list.get(i as u32));
}
}
}
```
Adding the #[inline] attribute cut the run time from ~2.5 seconds to about 1.0 seconds.
0 commit comments