Use compile-time StringLiteral#downcase instead of runtime String#downcase (#508)

This commit is contained in:
Sijawusz Pur Rahnama 2018-11-14 11:47:46 +01:00 committed by Serdar Dogruyol
parent 482b4a6e7d
commit 50f48509fd

View file

@ -11,7 +11,7 @@ module Kemal
macro only(paths, method = "GET") macro only(paths, method = "GET")
class_name = {{@type.name}} class_name = {{@type.name}}
method_downcase = {{method}}.downcase method_downcase = {{method.downcase}}
class_name_method = "#{class_name}/#{method_downcase}" class_name_method = "#{class_name}/#{method_downcase}"
({{paths}}).each do |path| ({{paths}}).each do |path|
@@only_routes_tree.add class_name_method + path, '/' + method_downcase + path @@only_routes_tree.add class_name_method + path, '/' + method_downcase + path
@ -20,7 +20,7 @@ module Kemal
macro exclude(paths, method = "GET") macro exclude(paths, method = "GET")
class_name = {{@type.name}} class_name = {{@type.name}}
method_downcase = {{method}}.downcase method_downcase = {{method.downcase}}
class_name_method = "#{class_name}/#{method_downcase}" class_name_method = "#{class_name}/#{method_downcase}"
({{paths}}).each do |path| ({{paths}}).each do |path|
@@exclude_routes_tree.add class_name_method + path, '/' + method_downcase + path @@exclude_routes_tree.add class_name_method + path, '/' + method_downcase + path