Skip to content

Commit

Permalink
Improve efficiency of endpoint for loop
Browse files Browse the repository at this point in the history
Replaced inefficient for loop with rust native function in endpoint.rs.

Signed-off-by: Andrew Yao <[email protected]>
  • Loading branch information
andr3wy authored and roypat committed May 8, 2024
1 parent 2bbbf0f commit 9839263
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/vmm/src/dumbo/tcp/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,7 @@ impl Endpoint {
// We have to remove the bytes up to end from receive_buf, by shifting the
// others to the beginning of the buffer, and updating receive_buf_left.
// Also, advance the rwnd edge of the inner connection.
// TODO: Maximum efficiency.
for j in 0..b.len() - end {
b[j] = b[j + end];
}
b.copy_within(end.., 0);
self.receive_buf_left -= end;
// Safe to unwrap because we assert that the response buffer is small
// enough.
Expand Down

0 comments on commit 9839263

Please sign in to comment.