diff --git a/src/database.rs b/src/database.rs index 2943c9b..e8b8ae4 100644 --- a/src/database.rs +++ b/src/database.rs @@ -44,7 +44,7 @@ impl Database { let formatted = server .description_raw .as_ref() - .and_then(|v| Some(server.build_formatted_description(v))); + .map(|v| server.build_formatted_description(v)); // Delete server if it's opted out if server.check_opt_out() { diff --git a/src/protocol.rs b/src/protocol.rs index 4a8b9dc..df7bd7f 100644 --- a/src/protocol.rs +++ b/src/protocol.rs @@ -101,6 +101,7 @@ impl PingableServer { } // returns the decoded varint and how many bytes were read +#[inline(always)] fn decode_varint(bytes: &[u8]) -> (usize, u8) { let mut value: usize = 0; let mut count: u8 = 0; diff --git a/src/response.rs b/src/response.rs index 6a421eb..cb5b504 100644 --- a/src/response.rs +++ b/src/response.rs @@ -152,7 +152,7 @@ impl Server { "color" => { if let Some(c) = value.as_str() { let color = MinecraftColorCodes::from(c.to_string()); - output.push_str(format!("§{}", color.get_code().to_string()).as_str()) + output.push_str(format!("§{}", color.get_code()).as_str()) } }, _ => (), diff --git a/src/scanner.rs b/src/scanner.rs index e2c3446..1946de6 100644 --- a/src/scanner.rs +++ b/src/scanner.rs @@ -254,6 +254,7 @@ impl Scanner { } } +#[inline(always)] async fn task_wrapper(socket: SocketAddrV4, pool: Database) { let server = PingableServer::new(socket); diff --git a/src/utils.rs b/src/utils.rs index 844a1a0..1772d13 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -18,11 +18,11 @@ pub enum RunError { DatabaseError(#[from] sqlx::Error), } -impl Into for RunError { - fn into(self) -> usize { +impl From for usize { + fn from(value: RunError) -> Self { use RunError::*; - match self { + match value { AddressParseError(_) => 0, IOError(_) => 1, MalformedResponse => 2,