From e537f067c589c4e0b206878a42169c743d3e3ff2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 27 Feb 2010 18:21:08 -0800 Subject: revactor: cleanups to avoid instance_eval instance_variable_{set,get} are faster, but equally ugly --- lib/rainbows/revactor.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/rainbows/revactor.rb') diff --git a/lib/rainbows/revactor.rb b/lib/rainbows/revactor.rb index 6ecf11b..5c813ff 100644 --- a/lib/rainbows/revactor.rb +++ b/lib/rainbows/revactor.rb @@ -30,8 +30,9 @@ module Rainbows # once a client is accepted, it is processed in its entirety here # in 3 easy steps: read request, call app, write app response def process_client(client) + io = client.instance_variable_get(:@_io) defined?(Fcntl::FD_CLOEXEC) and - client.instance_eval { @_io.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) } + io.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) rd_args = [ nil ] remote_addr = if ::Revactor::TCP::Socket === client rd_args << RD_ARGS @@ -68,7 +69,7 @@ module Rainbows end while alive and hp.reset.nil? and env.clear rescue ::Revactor::TCP::ReadError rescue => e - Error.write(client.instance_eval { @_io }, e) + Error.write(io, e) ensure client.close end @@ -86,7 +87,7 @@ module Rainbows revactorize_listeners.each do |l, close, accept| Actor.spawn(l, close, accept) do |l, close, accept| Actor.current.trap_exit = true - l.controller = l.instance_eval { @receiver = Actor.current } + l.controller = l.instance_variable_set(:@receiver, Actor.current) begin while nr >= limit l.disable if l.enabled? -- cgit v1.2.3-24-ge0c7