Skip to content

A platform for community discussion. Free, open, simple.

PERF: Load all common passwords in one go (#15986)

Jarek Radoszefb7e19325fd
diff --git a/lib/common_passwords/common_passwords.rb b/lib/common_passwords/common_passwords.rb
index 022cd81dee9..901a007b01b 100644
--- a/lib/common_passwords/common_passwords.rb
+++ b/lib/common_passwords/common_passwords.rb
@@ -44,10 +44,7 @@ class CommonPasswords
def self.load_passwords
passwords = File.readlines(PASSWORD_FILE)
- passwords.map!(&:chomp).each do |pwd|
- # slower, but a tad more compatible
- redis.sadd LIST_KEY, pwd
- end
+ redis.sadd LIST_KEY, passwords.map!(&:chomp)
rescue Errno::ENOENT
# tolerate this so we don't block signups
Rails.logger.error "Common passwords file #{PASSWORD_FILE} is not found! Common password checking is skipped."