yahns Ruby server user/dev discussion
 help / color / mirror / code / Atom feed
* [PATCH] proxy_pass: favor literal hash over arrays for error responses
@ 2015-05-09  9:11 Eric Wong
  0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-05-09  9:11 UTC (permalink / raw)
  To: yahns-public; +Cc: Eric Wong

Arrays are less verbose, but they have more bytecode overhead
which actually matters at runtime.
---
 extras/proxy_pass.rb    | 2 +-
 lib/yahns/proxy_pass.rb | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/extras/proxy_pass.rb b/extras/proxy_pass.rb
index b7fc87a..99ca6d6 100644
--- a/extras/proxy_pass.rb
+++ b/extras/proxy_pass.rb
@@ -200,7 +200,7 @@ class ProxyPass # :nodoc:
       logger = env['rack.logger'] and
         Yahns::Log.exception(logger, 'proxy_pass', e)
     end
-    [ 502, [ %w(Content-Length 0), %w(Content-Type text/plain) ], [] ]
+    [ 502, { 'Content-Length' => '0', 'Content-Type' => 'text/plain' }, [] ]
   end
 
   def send_body(input, ures, chunked)
diff --git a/lib/yahns/proxy_pass.rb b/lib/yahns/proxy_pass.rb
index 15ae17c..7bbab51 100644
--- a/lib/yahns/proxy_pass.rb
+++ b/lib/yahns/proxy_pass.rb
@@ -243,6 +243,6 @@ class Yahns::ProxyPass # :nodoc:
     [ 500, [], [] ]
   rescue => e
     Yahns::Log.exception(env['rack.logger'], 'proxy_pass', e)
-    [ 502, [ %w(Content-Length 0), %w(Content-Type text/plain) ], [] ]
+    [ 502, { 'Content-Length' => '0', 'Content-Type' => 'text/plain' }, [] ]
   end
 end
-- 
EW


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-05-09  9:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-09  9:11 [PATCH] proxy_pass: favor literal hash over arrays for error responses Eric Wong

Code repositories for project(s) associated with this public inbox

	https://yhbt.net/yahns.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).