directly match string instead of allocating a complete lowercase string

This commit is contained in:
Quaternions 2024-10-01 13:21:26 -07:00
parent fabd53423e
commit b96b26bb2d

View File

@ -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()))?,