mirror of https://github.com/m-labs/artiq.git
firmware: optimize integer array/list rpc
This commit is contained in:
parent
c229e76d07
commit
3832b261b1
|
@ -204,21 +204,19 @@ unsafe fn send_value<W>(writer: &mut W, tag: Tag, data: &mut *const ())
|
||||||
let mut data = (*ptr).elements;
|
let mut data = (*ptr).elements;
|
||||||
writer.write_u8(tag.as_u8())?;
|
writer.write_u8(tag.as_u8())?;
|
||||||
match tag {
|
match tag {
|
||||||
|
// we cannot use NetworkEndian::from_slice_i32 as the data is not mutable,
|
||||||
|
// and that is not needed as the data is already in network endian
|
||||||
Tag::Bool => {
|
Tag::Bool => {
|
||||||
let slice = slice::from_raw_parts(data as *const u8, length);
|
let slice = slice::from_raw_parts(data as *const u8, length);
|
||||||
writer.write_all(slice)?;
|
writer.write_all(slice)?;
|
||||||
},
|
},
|
||||||
Tag::Int32 => {
|
Tag::Int32 => {
|
||||||
let slice = slice::from_raw_parts(data as *const u32, length);
|
let slice = slice::from_raw_parts(data as *const u8, length * 4);
|
||||||
for v in slice.iter() {
|
writer.write_all(slice)?;
|
||||||
writer.write_u32(*v)?;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
Tag::Int64 | Tag::Float64 => {
|
Tag::Int64 | Tag::Float64 => {
|
||||||
let slice = slice::from_raw_parts(data as *const u64, length);
|
let slice = slice::from_raw_parts(data as *const u8, length * 8);
|
||||||
for v in slice.iter() {
|
writer.write_all(slice)?;
|
||||||
writer.write_u64(*v)?;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
for _ in 0..length {
|
for _ in 0..length {
|
||||||
|
@ -245,21 +243,19 @@ unsafe fn send_value<W>(writer: &mut W, tag: Tag, data: &mut *const ())
|
||||||
let mut data = *buffer;
|
let mut data = *buffer;
|
||||||
writer.write_u8(elt_tag.as_u8())?;
|
writer.write_u8(elt_tag.as_u8())?;
|
||||||
match elt_tag {
|
match elt_tag {
|
||||||
|
// we cannot use NetworkEndian::from_slice_i32 as the data is not mutable,
|
||||||
|
// and that is not needed as the data is already in network endian
|
||||||
Tag::Bool => {
|
Tag::Bool => {
|
||||||
let slice = slice::from_raw_parts(data as *const u8, length);
|
let slice = slice::from_raw_parts(data as *const u8, length);
|
||||||
writer.write_all(slice)?;
|
writer.write_all(slice)?;
|
||||||
},
|
},
|
||||||
Tag::Int32 => {
|
Tag::Int32 => {
|
||||||
let slice = slice::from_raw_parts(data as *const u32, length);
|
let slice = slice::from_raw_parts(data as *const u8, length * 4);
|
||||||
for v in slice.iter() {
|
writer.write_all(slice)?;
|
||||||
writer.write_u32(*v)?;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
Tag::Int64 | Tag::Float64 => {
|
Tag::Int64 | Tag::Float64 => {
|
||||||
let slice = slice::from_raw_parts(data as *const u64, length);
|
let slice = slice::from_raw_parts(data as *const u8, length * 8);
|
||||||
for v in slice.iter() {
|
writer.write_all(slice)?;
|
||||||
writer.write_u64(*v)?;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
for _ in 0..length {
|
for _ in 0..length {
|
||||||
|
|
Loading…
Reference in New Issue