Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request rack#742 from schneems/schneems/freeze-string
Missed optimizations
  • Loading branch information
spastorino committed Feb 2, 2015
2 parents ed90508 + 5f808aa commit 558cf20
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
15 changes: 9 additions & 6 deletions lib/rack/body_proxy.rb
Expand Up @@ -4,9 +4,12 @@ def initialize(body, &block)
@body, @block, @closed = body, block, false
end

def respond_to?(*args)
return false if args.first.to_s =~ /^to_ary$/
super or @body.respond_to?(*args)
def respond_to?(method_name, include_all=false)
case method_name
when :to_ary, 'to_ary'
return false
end
super or @body.respond_to?(method_name, include_all)
end

def close
Expand All @@ -31,9 +34,9 @@ def each(*args, &block)
@body.each(*args, &block)
end

def method_missing(*args, &block)
super if args.first.to_s =~ /^to_ary$/
@body.__send__(*args, &block)
def method_missing(method_name, *args, &block)
super if :to_ary == method_name
@body.__send__(method_name, *args, &block)
end
end
end
4 changes: 2 additions & 2 deletions lib/rack/directory.rb
Expand Up @@ -71,7 +71,7 @@ def check_forbidden

body = "Forbidden\n"
size = Rack::Utils.bytesize(body)
return [403, {"Content-Type" => "text/plain",
return [403, {CONTENT_TYPE => "text/plain",
CONTENT_LENGTH => size.to_s,
"X-Cascade" => "pass"}, [body]]
end
Expand Down Expand Up @@ -129,7 +129,7 @@ def list_path
def entity_not_found
body = "Entity not found: #{@path_info}\n"
size = Rack::Utils.bytesize(body)
return [404, {"Content-Type" => "text/plain",
return [404, {CONTENT_TYPE => "text/plain",
CONTENT_LENGTH => size.to_s,
"X-Cascade" => "pass"}, [body]]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rack/runtime.rb
Expand Up @@ -12,7 +12,7 @@ def initialize(app, name = nil)
@header_name << "-#{name}" if name
end

FORMAT_STRING = "%0.6f"
FORMAT_STRING = "%0.6f".freeze
def call(env)
start_time = clock_time
status, headers, body = @app.call(env)
Expand Down

0 comments on commit 558cf20

Please sign in to comment.