From 3ad03e5c30a7617aaba2276997bf2ccfdf5f0ec7 Mon Sep 17 00:00:00 2001 From: Kouta Imanaka Date: Wed, 15 Aug 2018 20:27:10 +0900 Subject: [PATCH] Rewrite logic using each_with_object with --- lib/apkstats/command/apk_analyzer.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/apkstats/command/apk_analyzer.rb b/lib/apkstats/command/apk_analyzer.rb index f88601d..96a8a7a 100644 --- a/lib/apkstats/command/apk_analyzer.rb +++ b/lib/apkstats/command/apk_analyzer.rb @@ -71,12 +71,10 @@ def self.to_feature(str) end def self.parse_reference_to_map(command_output) - reference_map = {} - command_output.split(/\r?\n/).map do |s| - dex_file, method_count = s.strip.split(/\t/) - reference_map[dex_file] = method_count + command_output.split(/\r?\n/).each_with_object({}) do |s, acc| + dex_file, method_count = s.strip.split(/\t/, 2) + acc[dex_file] = method_count end - reference_map end private