From efb7e19325fd64fcbd8799df461ffafc4a4f15ac Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Fri, 18 Feb 2022 19:47:15 +0100 Subject: [PATCH] PERF: Load all common passwords in one go (#15986) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Revert "BUGFIX: use a more widely compatible version of sadd" This reverts commit aa577f11fd5cb736c4904e47ba88c9ebb08e974a. I think the compatibility might not be a problem anymore, after 8 years? 😃 --- lib/common_passwords/common_passwords.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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."