1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

cache strings in the AST for faster comparison than include?

This commit is contained in:
Aaron Patterson 2011-05-02 17:05:20 -07:00
parent dd7afdb2dc
commit af8c54be0a

View file

@ -35,18 +35,15 @@ module ActionDispatch
end
class Static
FILE_METHODS = %w(GET HEAD).freeze
def initialize(app, path, cache_control=nil)
@app = app
@file_handler = FileHandler.new(path, cache_control)
end
def call(env)
case env['REQUEST_METHOD']
when 'GET', 'HEAD'
path = env['PATH_INFO'].chomp('/')
method = env['REQUEST_METHOD']
if FILE_METHODS.include?(method)
if match = @file_handler.match?(path)
env["PATH_INFO"] = match
return @file_handler.call(env)