Skip to content

Commit

Permalink
Some improvements
Browse files Browse the repository at this point in the history
- Cleanup if statement without !
- Remove `return` in favor or using `else`
- use `.map_or_else()`
  • Loading branch information
wcampbell0x2a authored and jim-signal committed Feb 10, 2021
1 parent 8c9259f commit 60dc1e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/rust/src/core/call_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,9 @@ where

// If not busy, create a new direct call.
let mut busy = self.busy.lock()?;
if !*busy {
if *busy {
Err(RingRtcError::CallManagerIsBusy.into())
} else {
let mut active_call_id = self.active_call_id.lock()?;
match *active_call_id {
Some(v) => Err(RingRtcError::CallAlreadyInProgress(v).into()),
Expand All @@ -903,8 +905,6 @@ where
call.inject_start_call()
}
}
} else {
Err(RingRtcError::CallManagerIsBusy.into())
}
}

Expand Down Expand Up @@ -969,11 +969,11 @@ where
let mut active_call = check_active_call!(self, "handle_proceed");
if active_call.call_id() != call_id {
ringbenchx!(RingBench::CM, RingBench::App, "inactive call_id");
return Ok(());
Ok(())
} else {
active_call.set_call_context(app_call_context)?;
active_call.inject_proceed(bandwidth_mode)
}

active_call.set_call_context(app_call_context)?;
active_call.inject_proceed(bandwidth_mode)
}

/// Handle message_sent() API from application.
Expand Down
6 changes: 2 additions & 4 deletions src/rust/src/webrtc/peer_connection_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,9 @@ impl PeerConnectionFactory {
hide_ip,
ice_servers.rffi(),
outgoing_audio_track.rffi(),
if let Some(outgoing_video_track) = outgoing_video_track {
outgoing_video_track.map_or_else(std::ptr::null, |outgoing_video_track| {
outgoing_video_track.rffi()
} else {
std::ptr::null()
},
}),
enable_dtls,
enable_rtp_data_channel,
)
Expand Down

0 comments on commit 60dc1e1

Please sign in to comment.