mirror of
https://github.com/YGGverse/ggemini.git
synced 2026-03-31 17:15:31 +00:00
minor optimizations
This commit is contained in:
parent
998a4e97b4
commit
c9d5e5987c
1 changed files with 6 additions and 13 deletions
|
|
@ -40,19 +40,12 @@ pub fn move_all_from_stream_async(
|
||||||
memory_input_stream: MemoryInputStream,
|
memory_input_stream: MemoryInputStream,
|
||||||
cancellable: Cancellable,
|
cancellable: Cancellable,
|
||||||
priority: Priority,
|
priority: Priority,
|
||||||
bytes: (
|
(bytes_in_chunk, bytes_total_limit, mut bytes_total): (usize, usize, usize),
|
||||||
usize, // bytes_in_chunk
|
(on_chunk, on_complete): (
|
||||||
usize, // bytes_total_limit
|
impl Fn(Bytes, usize) + 'static,
|
||||||
usize, // bytes_total
|
impl FnOnce(Result<(MemoryInputStream, usize), Error>) + 'static,
|
||||||
),
|
|
||||||
callback: (
|
|
||||||
impl Fn(Bytes, usize) + 'static, // on_chunk
|
|
||||||
impl FnOnce(Result<(MemoryInputStream, usize), Error>) + 'static, // on_complete
|
|
||||||
),
|
),
|
||||||
) {
|
) {
|
||||||
let (on_chunk, on_complete) = callback;
|
|
||||||
let (bytes_in_chunk, bytes_total_limit, bytes_total) = bytes;
|
|
||||||
|
|
||||||
base_io_stream.input_stream().read_bytes_async(
|
base_io_stream.input_stream().read_bytes_async(
|
||||||
bytes_in_chunk,
|
bytes_in_chunk,
|
||||||
priority,
|
priority,
|
||||||
|
|
@ -60,7 +53,7 @@ pub fn move_all_from_stream_async(
|
||||||
move |result| match result {
|
move |result| match result {
|
||||||
Ok(bytes) => {
|
Ok(bytes) => {
|
||||||
// Update bytes total
|
// Update bytes total
|
||||||
let bytes_total = bytes_total + bytes.len();
|
bytes_total += bytes.len();
|
||||||
|
|
||||||
// Callback chunk function
|
// Callback chunk function
|
||||||
on_chunk(bytes.clone(), bytes_total);
|
on_chunk(bytes.clone(), bytes_total);
|
||||||
|
|
@ -92,5 +85,5 @@ pub fn move_all_from_stream_async(
|
||||||
on_complete(Err(Error::InputStream(e)));
|
on_complete(Err(Error::InputStream(e)));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue