Reduce String creations in HelperMethodBuilder.get()

This commit is contained in:
Akira Matsuda 2019-08-16 22:48:40 +09:00
parent bbb35d94e1
commit 09ad1ec0bf
1 changed files with 6 additions and 6 deletions

View File

@ -173,15 +173,15 @@ module ActionDispatch
end
class HelperMethodBuilder # :nodoc:
CACHE = { "path" => {}, "url" => {} }
CACHE = { path: {}, url: {} }
def self.get(action, type)
type = type.to_s
type = type.to_sym
CACHE[type].fetch(action) { build action, type }
end
def self.url; CACHE["url"][nil]; end
def self.path; CACHE["path"][nil]; end
def self.url; CACHE[:url][nil]; end
def self.path; CACHE[:path][nil]; end
def self.build(action, type)
prefix = action ? "#{action}_" : ""
@ -340,8 +340,8 @@ module ActionDispatch
end
[nil, "new", "edit"].each do |action|
CACHE["url"][action] = build action, "url"
CACHE["path"][action] = build action, "path"
CACHE[:url][action] = build action, "url"
CACHE[:path][action] = build action, "path"
end
end
end