ruby-changes:49776
From: normal <ko1@a...>
Date: Thu, 18 Jan 2018 09:52:06 +0900 (JST)
Subject: [ruby-changes:49776] normal:r61894 (trunk): logger: use safe navigation operator
normal 2018-01-18 09:52:01 +0900 (Thu, 18 Jan 2018) New Revision: 61894 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61894 Log: logger: use safe navigation operator Saves a few hundred bytes of bytecode in a frequently loaded module. Modified files: trunk/lib/logger.rb Index: lib/logger.rb =================================================================== --- lib/logger.rb (revision 61893) +++ lib/logger.rb (revision 61894) @@ -479,9 +479,7 @@ class Logger https://github.com/ruby/ruby/blob/trunk/lib/logger.rb#L479 # device exists, return +nil+. # def <<(msg) - unless @logdev.nil? - @logdev.write(msg) - end + @logdev&.write(msg) end # @@ -568,7 +566,7 @@ class Logger https://github.com/ruby/ruby/blob/trunk/lib/logger.rb#L566 # Close the logging device. # def close - @logdev.close if @logdev + @logdev&.close end private -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/