diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-06-11 15:02:42 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-06-11 15:32:53 -0700 |
commit | 5825eea4b139b9af089c3075d042d5d3160583ec (patch) | |
tree | fd79641ded1857ee4166b6e9ba774a35ab47b06b /lib/chef/win32 | |
parent | 3889eddfc9944b23caea412d05c08b9b156cb50f (diff) | |
download | chef-5825eea4b139b9af089c3075d042d5d3160583ec.tar.gz |
Use .match? not =~ when match values aren't necessary
Autocorrected from RuboCop Performance which is now smart enough to detect when you use the match and when you don't. Using match? does not create any objects so it's slightly faster and uses less memory.
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/chef/win32')
-rw-r--r-- | lib/chef/win32/file.rb | 2 | ||||
-rw-r--r-- | lib/chef/win32/registry.rb | 4 | ||||
-rw-r--r-- | lib/chef/win32/security.rb | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/lib/chef/win32/file.rb b/lib/chef/win32/file.rb index d6f6a61d9a..e051a53e4d 100644 --- a/lib/chef/win32/file.rb +++ b/lib/chef/win32/file.rb @@ -123,7 +123,7 @@ class Chef # Return the link destination (strip off \??\ at the beginning, which is a local filesystem thing) link_dest = reparse_buffer.reparse_buffer.substitute_name - if link_dest =~ /^\\\?\?\\/ + if /^\\\?\?\\/.match?(link_dest) link_dest = link_dest[4..-1] end link_dest diff --git a/lib/chef/win32/registry.rb b/lib/chef/win32/registry.rb index a5c63b571b..c31ae50e0b 100644 --- a/lib/chef/win32/registry.rb +++ b/lib/chef/win32/registry.rb @@ -20,7 +20,7 @@ require_relative "../reserved_names" require_relative "api" require_relative "../mixin/wide_string" -if RUBY_PLATFORM =~ /mswin|mingw32|windows/ +if RUBY_PLATFORM.match?(/mswin|mingw32|windows/) require_relative "../monkey_patches/win32/registry" require_relative "api/registry" require "win32/registry" unless defined?(Win32::Registry) @@ -31,7 +31,7 @@ class Chef class Win32 class Registry - if RUBY_PLATFORM =~ /mswin|mingw32|windows/ + if RUBY_PLATFORM.match?(/mswin|mingw32|windows/) include Chef::ReservedNames::Win32::API::Registry extend Chef::ReservedNames::Win32::API::Registry end diff --git a/lib/chef/win32/security.rb b/lib/chef/win32/security.rb index cebf07208b..3894c65b21 100644 --- a/lib/chef/win32/security.rb +++ b/lib/chef/win32/security.rb @@ -694,7 +694,7 @@ class Chef begin process_token = open_current_process_token(TOKEN_READ) rescue Exception => run_error - return false if run_error.message =~ /Access is denied/ + return false if /Access is denied/.match?(run_error.message) Chef::ReservedNames::Win32::Error.raise! end |