From b96b26bb2d75646fb8d60feaa7d75335d6e4c31e Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 1 Oct 2024 13:21:26 -0700 Subject: [PATCH] directly match string instead of allocating a complete lowercase string --- src/rbxassetid.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/rbxassetid.rs b/src/rbxassetid.rs index daf227c..53eb682 100644 --- a/src/rbxassetid.rs +++ b/src/rbxassetid.rs @@ -16,9 +16,10 @@ impl std::str::FromStr for RobloxAssetId{ "rbxassetid"=>url.domain().ok_or_else(||RobloxAssetIdParseErr::MissingAssetId(s.to_owned()))?.parse(), "http"|"https"=>{ let (_,asset_id)=url.query_pairs() - .find(|(id,_)| - id.to_lowercase()=="id" - ).ok_or_else(||RobloxAssetIdParseErr::MissingAssetId(s.to_owned()))?; + .find(|(id,_)|match id.as_ref(){ + "ID"|"id"|"Id"|"iD"=>true, + _=>false, + }).ok_or_else(||RobloxAssetIdParseErr::MissingAssetId(s.to_owned()))?; asset_id.parse() }, _=>Err(RobloxAssetIdParseErr::UnknownScheme(s.to_owned()))?,