diff --git a/CHANGELOG.md b/CHANGELOG.md index fdc7d3a3e..9dda411fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ * [#2918](https://github.com/ruby-grape/grape/pull/2918): Skip the dry-types round trip when a value already is the declared type - [@ericproulx](https://github.com/ericproulx). * [#2917](https://github.com/ruby-grape/grape/pull/2917): Read path captures out of the router's union match instead of re-running the route's pattern - [@ericproulx](https://github.com/ericproulx). * [#2921](https://github.com/ruby-grape/grape/pull/2921): Pin the router's request-time isolation regressions through requests instead of its instance variables - [@ericproulx](https://github.com/ericproulx). +* [#2926](https://github.com/ruby-grape/grape/pull/2926): Skip the renamed-params lookup in `declared` when nothing is renamed - [@ericproulx](https://github.com/ericproulx). * Your contribution here. ### 4.0.0 (2026-09-07) diff --git a/lib/grape/declared_params_handler.rb b/lib/grape/declared_params_handler.rb index 5191a49d1..b8d57b4d3 100644 --- a/lib/grape/declared_params_handler.rb +++ b/lib/grape/declared_params_handler.rb @@ -87,8 +87,11 @@ def declare_leaf(passed_params, declared_param:, params_nested_path:, memo:, ren end end + # The lookup key is the param's whole path, built fresh -- two Arrays and a + # String per declared param -- and only an API using +as:+ has anything to + # find with it, so the common empty table is not asked. def build_memo_key(params_nested_path, declared_param, renamed_params) - renamed_param_name = renamed_params[nested_path_for(params_nested_path, declared_param)] + renamed_param_name = renamed_params[nested_path_for(params_nested_path, declared_param)] unless renamed_params.empty? param = renamed_param_name || declared_param @stringify ? param.to_s : param.to_sym end