Skip to content

Commit

Permalink
Reduce String creations in HelperMethodBuilder.get()
Browse files Browse the repository at this point in the history
  • Loading branch information
amatsuda committed Aug 18, 2019
1 parent bbb35d9 commit 09ad1ec
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ def polymorphic_mapping(record)
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}_" : ""
Expand Down Expand Up @@ -340,8 +340,8 @@ def get_method_for_string(str)
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
Expand Down

0 comments on commit 09ad1ec

Please sign in to comment.