From df916e86b79b731ce33d201ca4009b03001c30c3 Mon Sep 17 00:00:00 2001 From: Carson Reinke Date: Tue, 27 Oct 2015 12:27:37 -0400 Subject: [PATCH] compact! only returns array if changes were made --- lib/memory_diagnostics.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/memory_diagnostics.rb b/lib/memory_diagnostics.rb index e484bf51293..a49480677a9 100644 --- a/lib/memory_diagnostics.rb +++ b/lib/memory_diagnostics.rb @@ -21,8 +21,8 @@ module MemoryDiagnostics require 'objspace' diff = diff.map do |id| ObjectSpace._id2ref(id) rescue nil - end.compact! - diff ||= [] + end + diff.compact! report = "#{diff.length} objects have leaked\n"