summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-03-11 13:53:25 -0700
committerTim Smith <tsmith@chef.io>2018-03-11 15:48:56 -0700
commit5672d71c500c86bee3fe7e107933f5390f2c1ac9 (patch)
treed393fff84fb2b2662c996518de5af912835f89fe
parent84ea1415f0a31780d3ff03de340e32af23ff62c4 (diff)
downloadchef-5672d71c500c86bee3fe7e107933f5390f2c1ac9.tar.gz
Use Ruby 2.3's +'' instead of String.new
This is another Rubocop performance cop. Here's their description: ``` In Ruby 2.3 or later, use unary plus operator to unfreeze a string literal instead of String#dup and String.new. Unary plus operator is faster than String#dup. Note: String.new (without operator) is not exactly the same as +''. These differ in encoding. String.new.encoding is always ASCII-8BIT. However, (+'').encoding is the same as script encoding(e.g. UTF-8). So, if you expect ASCII-8BIT encoding, disable this cop. ``` Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/provider/cron.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/chef/provider/cron.rb b/lib/chef/provider/cron.rb
index c232585c18..ee5f408c01 100644
--- a/lib/chef/provider/cron.rb
+++ b/lib/chef/provider/cron.rb
@@ -95,8 +95,8 @@ class Chef
end
def action_create
- crontab = String.new
- newcron = String.new
+ crontab = +""
+ newcron = +""
cron_found = false
newcron = get_crontab_entry
@@ -156,7 +156,7 @@ class Chef
def action_delete
if @cron_exists
- crontab = String.new
+ crontab = +""
cron_found = false
read_crontab.each_line do |line|
case line.chomp