Add inline markers; simplify ip address conversion in request_from_bytes

This commit is contained in:
Joakim Frostegård 2020-04-08 11:19:03 +02:00
parent 4721fa3109
commit a865f4a1ae
6 changed files with 15 additions and 6 deletions

View file

@ -36,6 +36,7 @@ impl PeerStatus {
/// Determine peer status from announce event and number of bytes left.
///
/// Likely, the last branch will be taken most of the time.
#[inline]
pub fn from_event_and_bytes_left(
event: AnnounceEvent,
bytes_left: NumberOfBytes
@ -62,12 +63,14 @@ pub struct Peer {
impl Peer {
#[inline(always)]
pub fn to_response_peer(&self) -> ResponsePeer {
ResponsePeer {
ip_address: self.ip_address,
port: self.port
}
}
#[inline]
pub fn from_announce_and_ip(
announce_request: &AnnounceRequest,
ip_address: IpAddr

View file

@ -214,6 +214,7 @@ pub fn extract_response_peers(
}
#[inline(always)]
pub fn create_torrent_scrape_statistics(
seeders: i32,
leechers: i32