From e969c1490a9b01173c05d2c3a10df8aec802b51d Mon Sep 17 00:00:00 2001 From: syeopite Date: Fri, 24 Sep 2021 19:50:56 -0700 Subject: [PATCH] Fix Performance/ChainedCallWithNoBang issues --- src/invidious/helpers/tokens.cr | 4 ++-- src/invidious/jobs/pull_popular_videos_job.cr | 2 +- src/invidious/routes/api/manifest.cr | 2 +- src/invidious/yt_backend/proxy.cr | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/invidious/helpers/tokens.cr b/src/invidious/helpers/tokens.cr index e6d38315..3874799a 100644 --- a/src/invidious/helpers/tokens.cr +++ b/src/invidious/helpers/tokens.cr @@ -105,11 +105,11 @@ end def scope_includes_scope(scope, subset) methods, endpoint = scope.split(":") - methods = methods.split(";").map(&.upcase).reject(&.empty?).sort + methods = methods.split(";").map(&.upcase).reject(&.empty?).sort! endpoint = endpoint.downcase subset_methods, subset_endpoint = subset.split(":") - subset_methods = subset_methods.split(";").map(&.upcase).sort + subset_methods = subset_methods.split(";").map(&.upcase).sort! subset_endpoint = subset_endpoint.downcase if methods.empty? diff --git a/src/invidious/jobs/pull_popular_videos_job.cr b/src/invidious/jobs/pull_popular_videos_job.cr index 7a8ab84e..805016fd 100644 --- a/src/invidious/jobs/pull_popular_videos_job.cr +++ b/src/invidious/jobs/pull_popular_videos_job.cr @@ -16,7 +16,7 @@ class Invidious::Jobs::PullPopularVideosJob < Invidious::Jobs::BaseJob loop do videos = db.query_all(QUERY, as: ChannelVideo) .sort_by(&.published) - .reverse + .reverse! POPULAR_VIDEOS.set(videos) diff --git a/src/invidious/routes/api/manifest.cr b/src/invidious/routes/api/manifest.cr index f8963587..12687ec6 100644 --- a/src/invidious/routes/api/manifest.cr +++ b/src/invidious/routes/api/manifest.cr @@ -47,7 +47,7 @@ module Invidious::Routes::API::Manifest end audio_streams = video.audio_streams - video_streams = video.video_streams.sort_by { |stream| {stream["width"].as_i, stream["fps"].as_i} }.reverse + video_streams = video.video_streams.sort_by { |stream| {stream["width"].as_i, stream["fps"].as_i} }.reverse! manifest = XML.build(indent: " ", encoding: "UTF-8") do |xml| xml.element("MPD", "xmlns": "urn:mpeg:dash:schema:mpd:2011", diff --git a/src/invidious/yt_backend/proxy.cr b/src/invidious/yt_backend/proxy.cr index c66fd337..e150d887 100644 --- a/src/invidious/yt_backend/proxy.cr +++ b/src/invidious/yt_backend/proxy.cr @@ -236,7 +236,7 @@ def get_spys_proxies(country_code = "US") proxies << {ip: ip, port: port, score: score} end - proxies = proxies.sort_by { |proxy| proxy[:score] }.reverse + proxies = proxies.sort_by { |proxy| proxy[:score] }.reverse! return proxies end