From f729089f44ec2911d5a668c114b749c45d3df0f6 Mon Sep 17 00:00:00 2001 From: normal Date: Thu, 18 Jan 2018 00:52:01 +0000 Subject: [PATCH] logger: use safe navigation operator Saves a few hundred bytes of bytecode in a frequently loaded module. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/logger.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/logger.rb b/lib/logger.rb index 4ccc03b614..0615546d18 100644 --- a/lib/logger.rb +++ b/lib/logger.rb @@ -479,9 +479,7 @@ class Logger # device exists, return +nil+. # def <<(msg) - unless @logdev.nil? - @logdev.write(msg) - end + @logdev&.write(msg) end # @@ -568,7 +566,7 @@ class Logger # Close the logging device. # def close - @logdev.close if @logdev + @logdev&.close end private