diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-06-18 06:41:58 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-06-18 07:44:55 +0000 |
commit | ed9f3e90939cfa9efcc6e5e9382f1e1f40c49834 (patch) | |
tree | 32cda6265c16975daebe3c1f0c1430c622e2f608 /lib/rainbows/event_machine.rb | |
parent | 0e4014888f4f7f17d45c96677d672a538c6e6d94 (diff) | |
download | rainbows-ed9f3e90939cfa9efcc6e5e9382f1e1f40c49834.tar.gz |
Array#[] lookups are slightly faster under both rbx and 1.9, and easier to read.
Diffstat (limited to 'lib/rainbows/event_machine.rb')
-rw-r--r-- | lib/rainbows/event_machine.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/rainbows/event_machine.rb b/lib/rainbows/event_machine.rb index 12d9e5e..e5560d3 100644 --- a/lib/rainbows/event_machine.rb +++ b/lib/rainbows/event_machine.rb @@ -80,7 +80,7 @@ module Rainbows # too tricky to support pipelining with :async since the # second (pipelined) request could be a stuck behind a # long-running async response - (response.nil? || -1 == response.first) and return @state = :close + (response.nil? || -1 == response[0]) and return @state = :close alive = @hp.keepalive? && G.alive out = [ alive ? CONN_ALIVE : CONN_CLOSE ] if @hp.headers? @@ -99,7 +99,7 @@ module Rainbows end def response_write(response, out = [ CONN_CLOSE ], alive = false) - @body = body = response.last + @body = body = response[2] if body.respond_to?(:errback) && body.respond_to?(:callback) body.callback { quit } body.errback { quit } @@ -118,7 +118,7 @@ module Rainbows if st.file? headers.delete('Transfer-Encoding') headers['Content-Length'] ||= st.size.to_s - response = [ response.first, headers.to_hash, [] ] + response = [ response[0], headers.to_hash, [] ] HttpResponse.write(self, response, out) stream = stream_file_data(body.to_path) stream.callback { quit } unless alive @@ -130,7 +130,7 @@ module Rainbows else out[0] = CONN_CLOSE end - response = [ response.first, headers.to_hash, [] ] + response = [ response[0], headers.to_hash, [] ] HttpResponse.write(self, response, out) if do_chunk EM.watch(io, ResponseChunkPipe, self).notify_readable = true |