From 8c35cc957bcb9d3123d31e6c59ca628db796a11e Mon Sep 17 00:00:00 2001 From: Richard Jones Date: Mon, 4 Jul 2011 04:59:40 -0700 Subject: [PATCH] Create import_hash with .new(0) so that we don't have to check if a hash exists before incrementing it. --- lib/jekyll/migrators/wordpressdotcom.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/jekyll/migrators/wordpressdotcom.rb b/lib/jekyll/migrators/wordpressdotcom.rb index a4504043..ca6752ef 100644 --- a/lib/jekyll/migrators/wordpressdotcom.rb +++ b/lib/jekyll/migrators/wordpressdotcom.rb @@ -11,7 +11,7 @@ module Jekyll # wordpress.com blog (/wp-admin/export.php). module WordpressDotCom def self.process(filename = "wordpress.xml") - import_count = Hash.new + import_count = Hash.new(0) doc = Hpricot::XML(File.read(filename)) (doc/:channel/:item).each do |item| @@ -58,11 +58,8 @@ module Jekyll f.puts '---' f.puts item.at('content:encoded').inner_text end - if import_count[type] == nil - import_count[type] = 1 - else - import_count[type] += 1 - end + + import_count[type] += 1 end import_count.each do |key, value|