8000 Use safe navigation operator in layout helper (#8533) · activeadmin/activeadmin@25a6b36 · GitHub
[go: up one dir, main page]

Skip to content

Commit 25a6b36

Browse files
authored
Use safe navigation operator in layout helper (#8533)
Replace a logic `&&` with safe navigation operator now that Ruby < 2.3 support is not required anymore Benchmark (Ruby 3.3.5 x64 / M1 Pro): ``` Comparison (not `nil`): &.: 18787752.0 i/s &&: 17963968.8 i/s - 1.05x (± 0.00) slower Comparison (`nil`): &&: 21343215.5 i/s &.: 20910008.5 i/s - 1.02x (± 0.00) slower ``` Ref: #8530
1 parent 006abfc commit 25a6b36

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/helpers/active_admin/layout_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def html_head_site_title(separator: "-")
2222

2323
def action_items_for_action
2424
@action_items_for_action ||= begin
25-
if active_admin_config && active_admin_config.action_items?
25+
if active_admin_config&.action_items?
2626
active_admin_config.action_items_for(params[:action], self)
2727
else
2828
[]
@@ -32,7 +32,7 @@ def action_items_for_action
3232

3333
def sidebar_sections_for_action
3434
@sidebar_sections_for_action ||= begin
35-
if active_admin_config && active_admin_config.sidebar_sections?
35+
if active_admin_config&.sidebar_sections?
3636
active_admin_config.sidebar_sections_for(params[:action], self)
3737
else
3838
[]

0 commit comments

Comments
 (0)
0