about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorPostmodern <postmodern.mod3@gmail.com>2022-11-07 18:50:47 -0800
committerGitHub <noreply@github.com>2022-11-08 03:50:47 +0100
commitca80beb6530b3bbeff795c4832e2b4ab7bc8f672 (patch)
tree80317605799a94ca1e4ac8babbd617333c2b4659 /app/models
parent0beb095a4bfbcce55acb016eaaa54b5e93a56023 (diff)
Micro-optimization: use `if`/`else` instead of `Array#compact` and `Array#min` (#19906)
* Technically `if`/`else` is faster than using `[value1, value2].compact.min` to find the lesser of two values, one of which may be `nil`.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/account_statuses_cleanup_policy.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/models/account_statuses_cleanup_policy.rb b/app/models/account_statuses_cleanup_policy.rb
index 365123653..49adc6ad0 100644
--- a/app/models/account_statuses_cleanup_policy.rb
+++ b/app/models/account_statuses_cleanup_policy.rb
@@ -139,7 +139,12 @@ class AccountStatusesCleanupPolicy < ApplicationRecord
     # Filtering on `id` rather than `min_status_age` ago will treat
     # non-snowflake statuses as older than they really are, but Mastodon
     # has switched to snowflake IDs significantly over 2 years ago anyway.
-    max_id = [max_id, Mastodon::Snowflake.id_at(min_status_age.seconds.ago, with_random: false)].compact.min
+    snowflake_id = Mastodon::Snowflake.id_at(min_status_age.seconds.ago, with_random: false)
+
+    if max_id.nil? || snowflake_id < max_id
+      max_id = snowflake_id
+    end
+
     Status.where(Status.arel_table[:id].lteq(max_id))
   end