* [PATCH] proxy_pass: avoid needless regexp
@ 2015-04-07 21:34 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-04-07 21:34 UTC (permalink / raw)
To: yahns-public
A dumb string comparison will do here, so there's no point
in paying the memory and CPU cost of a regexp match when we
already extracted the suffix from a header key.
---
lib/yahns/proxy_pass.rb | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/yahns/proxy_pass.rb b/lib/yahns/proxy_pass.rb
index 48a61af..1b8eed7 100644
--- a/lib/yahns/proxy_pass.rb
+++ b/lib/yahns/proxy_pass.rb
@@ -223,7 +223,8 @@ class Yahns::ProxyPass # :nodoc:
# header in the request
next if /\A(?:VERSION|CONNECTION|KEEP_ALIVE|X_FORWARDED_FOR|TRAILER)/ =~
key
- chunked = true if %r{\ATRANSFER_ENCODING} =~ key && val =~ /\bchunked\b/i
+ 'TRANSFER_ENCODING'.freeze == key && val =~ /\bchunked\b/i and
+ chunked = true
key.tr!('_'.freeze, '-'.freeze)
req << "#{key}: #{val}\r\n"
end
--
EW
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-04-07 21:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-07 21:34 [PATCH] proxy_pass: avoid needless regexp 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).