From 087ff14d6117ef746bfad797a8088a7e6b74d5ac Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sat, 19 Apr 2008 11:39:18 +0200 Subject: rss plugin: return from select_nonempty() as soon as nonempty is found Don't map over all parameters, because some parameters might not respond to empty?. Also, it's unnecessarily slow. Just return as soon as we found a nonempty parameter. --- data/rbot/plugins/rss.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'data') diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb index 1d141f3b..ae2c0233 100644 --- a/data/rbot/plugins/rss.rb +++ b/data/rbot/plugins/rss.rb @@ -938,8 +938,8 @@ class RSSFeedsPlugin < Plugin def select_nonempty(*ar) debug ar - ret = ar.map { |i| (i && i.empty?) ? nil : i }.compact.first - (ret && ret.empty?) ? nil : ret + ar.each { |i| return i unless i.nil_or_empty? } + return nil end def printFormattedRss(feed, item, opts=nil) -- cgit v1.2.3