From 1b43717a31990d820fc3df637b7f19e9fcac4983 Mon Sep 17 00:00:00 2001 From: Compositr Date: Tue, 4 Mar 2025 09:46:29 +1100 Subject: [PATCH] perf: remove unused enum member --- src/http/responses.rs | 9 +-------- src/main.rs | 4 ++-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/http/responses.rs b/src/http/responses.rs index f8f9799..acc2e4b 100644 --- a/src/http/responses.rs +++ b/src/http/responses.rs @@ -3,7 +3,6 @@ use std::{error::Error, io::prelude::*, net::TcpStream}; use super::requests::Request; pub enum Body { - String(String), Static(&'static str), Bytes(Vec, &'static str), } @@ -57,7 +56,6 @@ fn send_response(mut stream: TcpStream, status: u16, body: Body) -> UnitOrBoxedE response.push_str(&format!( "Content-Length: {}\r\n", match &body { - Body::String(s) => s.len(), Body::Static(s) => s.len(), Body::Bytes(b, _) => b.len(), } @@ -68,16 +66,11 @@ fn send_response(mut stream: TcpStream, status: u16, body: Body) -> UnitOrBoxedE response.push_str("Cache-Control: immutable, public, max-age=604800\r\n"); } Body::Static(_) => response.push_str("Content-Type: text/plain; charset=utf-8\r\n"), - _ => {} } response.push_str("\r\n"); // Body - match &body { - Body::String(s) => response.push_str(s), - Body::Static(s) => response.push_str(s), - _ => {} - } + if let Body::Static(s) = &body { response.push_str(s) } match stream.write(response.as_bytes()) { Ok(_) => {} diff --git a/src/main.rs b/src/main.rs index 14d777f..3f749e2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -133,7 +133,7 @@ fn main() { } } - if let Some(_) = req.url.query.get("discord_compatibility") { + if req.url.query.contains_key("discord_compatibility") { padding = 8; } @@ -162,7 +162,7 @@ fn main() { icon_string = icon_string.replace("currentColor", svg_stroke); let mut backwards_compatibility = false; - if let Some(_) = req.url.query.get("backwards_compatibility") { + if req.url.query.contains_key("backwards_compatibility") { backwards_compatibility = true; // Icons were 80x80 plus 8px of padding; Icons start at 24x24 now so: 80 - 8 = 72, 72 / 24 = 3 therefore scale is 3x. scale = 3;