Skip to content

Commit

Permalink
Use ok_or_elese for lazy heap alloc.
Browse files Browse the repository at this point in the history
  • Loading branch information
th4s committed May 21, 2024
1 parent 1d0b2ab commit 94d01f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions crates/mpz-ole/src/rot/receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ where
F: Field + Serialize + Deserialize,
{
async fn receive(&mut self, ctx: &mut Ctx, b_k: Vec<F>) -> Result<Vec<F>, OLEError> {
let (receiver_adjust, adjust) = self.core.adjust(b_k).ok_or(OLEError::new(
OLEErrorKind::InsufficientOLEs,
"Not enough OLEs available".into(),
))?;
let (receiver_adjust, adjust) = self.core.adjust(b_k).ok_or_else(|| {
OLEError::new(
OLEErrorKind::InsufficientOLEs,
"Not enough OLEs available".into(),
)
})?;

let channel = ctx.io_mut();
channel.send(adjust).await?;
Expand Down
10 changes: 6 additions & 4 deletions crates/mpz-ole/src/rot/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ where
F: Field + Serialize + Deserialize,
{
async fn send(&mut self, ctx: &mut Ctx, a_k: Vec<F>) -> Result<Vec<F>, OLEError> {
let (sender_adjust, adjust) = self.core.adjust(a_k).ok_or(OLEError::new(
OLEErrorKind::InsufficientOLEs,
"Not enough OLEs available".into(),
))?;
let (sender_adjust, adjust) = self.core.adjust(a_k).ok_or_else(|| {
OLEError::new(
OLEErrorKind::InsufficientOLEs,
"Not enough OLEs available".into(),
)
})?;

let channel = ctx.io_mut();
channel.send(adjust).await?;
Expand Down

0 comments on commit 94d01f4

Please sign in to comment.