mirror of https://github.com/rails/rails
Reduce String creations in HelperMethodBuilder.get()
This commit is contained in:
parent
bbb35d94e1
commit
09ad1ec0bf
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue