From 6c91dc43ef2edcb80b0042cba67145a096945ed5 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sun, 28 Jul 2013 08:02:09 +0200 Subject: [PATCH] Minor optimization --- mark2.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mark2.rb b/mark2.rb index 62563fa..81a3385 100644 --- a/mark2.rb +++ b/mark2.rb @@ -60,8 +60,11 @@ class ChanceHash def decrease(el) if @hash.key?(el) - @hash[el] -= 1 - @hash.delete(el) if @hash[el] == 0 + if @hash[el] == 1 + @hash.delete(el) + else + @hash[el] -= 1 + end end @valid_pick = false return @hash[el] -- 2.32.0.93.g670b81a890