From a8566c9848122474b92fc8989eec196d5f4fb69b Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Fri, 5 Aug 2016 22:01:32 +0800 Subject: various: eliminate the usage of `any?` (#638) `any?` is not the opposite of `empty?`. Besides the case that `[false, nil].any?` will return false, `any?`(O(n)) has much worse performance than `empty?`(O(1)).--- Library/Homebrew/utils/inreplace.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Library/Homebrew/utils/inreplace.rb') diff --git a/Library/Homebrew/utils/inreplace.rb b/Library/Homebrew/utils/inreplace.rb index 149994223..9978b02fe 100644 --- a/Library/Homebrew/utils/inreplace.rb +++ b/Library/Homebrew/utils/inreplace.rb @@ -28,12 +28,12 @@ module Utils s.gsub!(before, after, audit_result) end - errors[path] = s.errors if s.errors.any? + errors[path] = s.errors unless s.errors.empty? Pathname(path).atomic_write(s) end - raise InreplaceError.new(errors) if errors.any? + raise InreplaceError.new(errors) unless errors.empty? end module_function :inreplace end -- cgit v1.2.3