From 7d1e738057cead1970d8aca31310a51a59f7235f Mon Sep 17 00:00:00 2001 From: Andrew White Date: Mon, 20 Feb 2017 13:55:29 +0000 Subject: Don't allocate a hash unnecessarily --- actionpack/lib/action_dispatch/routing/mapper.rb | 2 +- actionpack/lib/action_dispatch/routing/route_set.rb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index fceadc7039..3756ef15a2 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -2055,7 +2055,7 @@ module ActionDispatch # # NOTE: It is the url helper's responsibility to return the correct # set of options to be passed to the `url_for` call. - def direct(name, options = {}, &block) + def direct(name, options = nil, &block) case name when String, Symbol @set.add_url_helper(name, options, &block) diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index b1f7cd30fc..923d063655 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -210,7 +210,11 @@ module ActionDispatch private def eval_block(t, args, options) - t.instance_exec(*args, defaults.merge(options), &block) + t.instance_exec(*args, merge_defaults(options), &block) + end + + def merge_defaults(options) + defaults ? defaults.merge(options) : options end end -- cgit v1.2.3