From 6720cdda4b890ac42806a8fe290f96449a150c6a Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 24 Dec 2010 16:48:50 -0800 Subject: eliminate unnecessary freeze and dup They're not needed and a waste of code. --- lib/clogger.rb | 20 ++++++++++---------- lib/clogger/format.rb | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'lib') diff --git a/lib/clogger.rb b/lib/clogger.rb index 1d4e012..0eeea5b 100644 --- a/lib/clogger.rb +++ b/lib/clogger.rb @@ -57,7 +57,7 @@ private path_info query_string script_name server_name server_port auth_type gateway_interface server_software path_translated - ).join('|') << ')\z').freeze + ).join('|') << ')\z') SCAN = /([^$]*)(\$+(?:env\{\w+(?:\.[\w\.]+)?\}| e\{[^\}]+\}| @@ -73,28 +73,28 @@ private unless tok.nil? if tok.sub!(/\A(\$+)\$/, '$') - rv << [ OP_LITERAL, $1.dup ] + rv << [ OP_LITERAL, $1 ] end compat = ALIASES[tok] and tok = compat case tok when /\A(\$*)\z/ - rv << [ OP_LITERAL, $1.dup ] + rv << [ OP_LITERAL, $1 ] when /\A\$env\{(\w+(?:\.[\w\.]+))\}\z/ - rv << [ OP_REQUEST, $1.freeze ] + rv << [ OP_REQUEST, $1 ] when /\A\$e\{([^\}]+)\}\z/ - rv << [ OP_EVAL, $1.dup ] + rv << [ OP_EVAL, $1 ] when /\A\$cookie_(\w+)\z/ - rv << [ OP_COOKIE, $1.dup.freeze ] + rv << [ OP_COOKIE, $1 ] when CGI_ENV, /\A\$(http_\w+)\z/ - rv << [ OP_REQUEST, $1.upcase.freeze ] + rv << [ OP_REQUEST, $1.upcase ] when /\A\$sent_http_(\w+)\z/ - rv << [ OP_RESPONSE, $1.downcase.tr('_','-').freeze ] + rv << [ OP_RESPONSE, $1.downcase.tr('_','-') ] when /\A\$time_local\{([^\}]+)\}\z/ - rv << [ OP_TIME_LOCAL, $1.dup ] + rv << [ OP_TIME_LOCAL, $1 ] when /\A\$time_utc\{([^\}]+)\}\z/ - rv << [ OP_TIME_UTC, $1.dup ] + rv << [ OP_TIME_UTC, $1 ] when /\A\$time\{(\d+)\}\z/ rv << [ OP_TIME, *usec_conv_pair(tok, $1.to_i) ] when /\A\$request_time\{(\d+)\}\z/ diff --git a/lib/clogger/format.rb b/lib/clogger/format.rb index 9e4f59f..54fe766 100644 --- a/lib/clogger/format.rb +++ b/lib/clogger/format.rb @@ -7,19 +7,19 @@ class Clogger # common log format used by Apache: # http://httpd.apache.org/docs/2.2/logs.html Common = "$remote_addr - $remote_user [$time_local] " \ - '"$request" $status $response_length'.freeze + '"$request" $status $response_length' # combined log format used by Apache: # http://httpd.apache.org/docs/2.2/logs.html - Combined = %Q|#{Common} "$http_referer" "$http_user_agent"|.freeze + Combined = %Q|#{Common} "$http_referer" "$http_user_agent"| # combined log format used by nginx: # http://wiki.nginx.org/NginxHttpLogModule - NginxCombined = Combined.gsub(/response_length/, 'body_bytes_sent').freeze + NginxCombined = Combined.gsub(/response_length/, 'body_bytes_sent') # log format used by Rack 1.0 Rack_1_0 = "$ip - $remote_user [$time_local{%d/%b/%Y %H:%M:%S}] " \ - '"$request" $status $response_length $request_time{4}'.freeze + '"$request" $status $response_length $request_time{4}' end end -- cgit v1.2.3-24-ge0c7