From ed9f3e90939cfa9efcc6e5e9382f1e1f40c49834 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 18 Jun 2010 06:41:58 +0000 Subject: prefer Array#[] lookup to Array#first/Array#last Array#[] lookups are slightly faster under both rbx and 1.9, and easier to read. --- lib/rainbows/thread_pool.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/rainbows/thread_pool.rb') diff --git a/lib/rainbows/thread_pool.rb b/lib/rainbows/thread_pool.rb index a68fcc6..6fce3c1 100644 --- a/lib/rainbows/thread_pool.rb +++ b/lib/rainbows/thread_pool.rb @@ -42,7 +42,7 @@ module Rainbows end def sync_worker - s = LISTENERS.first + s = LISTENERS[0] begin c = Rainbows.sync_accept(s) and process_client(c) rescue => e @@ -57,7 +57,7 @@ module Rainbows # all working off the same socket could be a thundering herd # problem. On the other hand, a thundering herd may not # even incur as much overhead as an extra Mutex#synchronize - ret = IO.select(LISTENERS, nil, nil, 1) and ret.first.each do |s| + ret = IO.select(LISTENERS, nil, nil, 1) and ret[0].each do |s| s = Rainbows.accept(s) and process_client(s) end rescue Errno::EINTR -- cgit v1.2.3-24-ge0c7