Optimize various case-insensitive comparisons.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -133,8 +133,8 @@ pub(crate) async fn get_state_events_for_key_route(
|
||||
|
||||
let event_format = body
|
||||
.format
|
||||
.as_ref()
|
||||
.is_some_and(|f| f.to_lowercase().eq("event"));
|
||||
.as_deref()
|
||||
.is_some_and(|f| f.eq_ignore_ascii_case("event"));
|
||||
|
||||
Ok(get_state_event_for_key::v3::Response {
|
||||
content: event_format.or(|| event.get_content_as_value()),
|
||||
|
||||
@@ -224,7 +224,7 @@ async fn download_html(&self, _url: &str) -> Result<UrlPreviewData> {
|
||||
pub fn url_preview_allowed(&self, url: &Url) -> bool {
|
||||
if ["http", "https"]
|
||||
.iter()
|
||||
.all(|&scheme| scheme != url.scheme().to_lowercase())
|
||||
.all(|&scheme| !scheme.eq_ignore_ascii_case(url.scheme()))
|
||||
{
|
||||
debug!("Ignoring non-HTTP/HTTPS URL to preview: {}", url);
|
||||
return false;
|
||||
|
||||
@@ -69,11 +69,11 @@ pub fn get_config(&self, id: &str) -> Result<Provider> {
|
||||
|
||||
if let Some(provider) = providers
|
||||
.values()
|
||||
.find(|config| config.brand == id.to_lowercase())
|
||||
.find(|config| config.brand.eq_ignore_ascii_case(id))
|
||||
.filter(|_| {
|
||||
providers
|
||||
.values()
|
||||
.filter(|config| config.brand == id.to_lowercase())
|
||||
.filter(|config| config.brand.eq_ignore_ascii_case(id))
|
||||
.count()
|
||||
.eq(&1)
|
||||
})
|
||||
@@ -97,11 +97,11 @@ async fn get_cached(&self, id: &str) -> Option<Provider> {
|
||||
|
||||
providers
|
||||
.values()
|
||||
.find(|provider| provider.brand == id.to_lowercase())
|
||||
.find(|provider| provider.brand.eq_ignore_ascii_case(id))
|
||||
.filter(|_| {
|
||||
providers
|
||||
.values()
|
||||
.filter(|provider| provider.brand == id.to_lowercase())
|
||||
.filter(|provider| provider.brand.eq_ignore_ascii_case(id))
|
||||
.count()
|
||||
.eq(&1)
|
||||
})
|
||||
|
||||
@@ -104,7 +104,7 @@ pub async fn set_pusher(
|
||||
|
||||
if ["http", "https"]
|
||||
.iter()
|
||||
.all(|&scheme| scheme != url.scheme().to_lowercase())
|
||||
.all(|&scheme| !scheme.eq_ignore_ascii_case(url.scheme()))
|
||||
{
|
||||
return Err!(Request(InvalidParam(
|
||||
warn!(%url, "HTTP pusher URL is not a valid HTTP/HTTPS URL")
|
||||
|
||||
@@ -97,7 +97,7 @@ async fn send_notice<Pdu: Event>(
|
||||
|
||||
if ["http", "https"]
|
||||
.iter()
|
||||
.all(|&scheme| scheme != url.scheme().to_lowercase())
|
||||
.all(|&scheme| !scheme.eq_ignore_ascii_case(url.scheme()))
|
||||
{
|
||||
return Err!(Request(InvalidParam(
|
||||
warn!(%url, "HTTP pusher URL is not a valid HTTP/HTTPS URL")
|
||||
|
||||
Reference in New Issue
Block a user