Skip to content

Commit

Permalink
rpc: actually use size hint in new_outgoing_message
Browse files Browse the repository at this point in the history
  • Loading branch information
dwrensha committed Jun 1, 2024
1 parent cd5bf1f commit 696cdb9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
12 changes: 6 additions & 6 deletions capnp-rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl<VatId> Drop for QuestionRef<VatId> {
match &mut questions.slots[self.id as usize] {
Some(q) => {
if let Ok(ref mut c) = *self.connection_state.connection.borrow_mut() {
let mut message = c.new_outgoing_message(100); // XXX size hint
let mut message = c.new_outgoing_message(5);
{
let root: message::Builder = message.get_body().unwrap().init_as();
let mut builder = root.init_finish();
Expand Down Expand Up @@ -629,7 +629,7 @@ impl<VatId> ConnectionState<VatId> {
}
match *state.connection.borrow_mut() {
Ok(ref mut c) => {
let mut message = c.new_outgoing_message(100); // TODO estimate size
let mut message = c.new_outgoing_message(5);
{
let mut builder = message
.get_body()
Expand Down Expand Up @@ -739,7 +739,7 @@ impl<VatId> ConnectionState<VatId> {
return Ok(());
}

let mut response = connection_state.new_outgoing_message(50)?; // XXX size hint
let mut response = connection_state.new_outgoing_message(10)?;

let result_exports = {
let mut ret = response
Expand Down Expand Up @@ -1761,7 +1761,7 @@ where
_size_hint: Option<::capnp::MessageSize>,
target: Client<VatId>,
) -> ::capnp::Result<Self> {
let message = connection_state.new_outgoing_message(100)?;
let message = connection_state.new_outgoing_message(1024)?;
Ok(Self {
connection_state,
target,
Expand Down Expand Up @@ -2392,7 +2392,7 @@ impl ResultsDone {
if let Ok(connection) =
connection_state.connection.borrow_mut().as_mut()
{
let mut message = connection.new_outgoing_message(50); // XXX size hint
let mut message = connection.new_outgoing_message(10);
{
let root: message::Builder =
message.get_body()?.get_as()?;
Expand Down Expand Up @@ -2627,7 +2627,7 @@ impl<VatId> Drop for ImportClient<VatId> {
// Send a message releasing our remote references.
let mut tmp = connection_state.connection.borrow_mut();
if let (true, Ok(c)) = (self.remote_ref_count > 0, tmp.as_mut()) {
let mut message = c.new_outgoing_message(50); // XXX size hint
let mut message = c.new_outgoing_message(10);
{
let root: message::Builder = message.get_body().unwrap().init_as();
let mut release = root.init_release();
Expand Down
8 changes: 6 additions & 2 deletions capnp-rpc/src/twoparty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,14 @@ where

fn new_outgoing_message(
&mut self,
_first_segment_word_size: u32,
first_segment_word_size: u32,
) -> Box<dyn crate::OutgoingMessage> {
let message = ::capnp::message::Builder::new(
::capnp::message::HeapAllocator::new()
.first_segment_words(first_segment_word_size as u32),

Check warning on line 156 in capnp-rpc/src/twoparty.rs

View workflow job for this annotation

GitHub Actions / lint

casting to the same type is unnecessary (`u32` -> `u32`)

warning: casting to the same type is unnecessary (`u32` -> `u32`) --> capnp-rpc/src/twoparty.rs:156:38 | 156 | .first_segment_words(first_segment_word_size as u32), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `first_segment_word_size` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast = note: `#[warn(clippy::unnecessary_cast)]` on by default
);
Box::new(OutgoingMessage {
message: ::capnp::message::Builder::new_default(),
message,
sender: self.inner.borrow().sender.clone(),
})
}
Expand Down

0 comments on commit 696cdb9

Please sign in to comment.