Skip to content

Conversation

@tagliala
Copy link
Contributor

@tagliala tagliala commented Nov 2, 2024

Replace a logic && with safe navigation operator now that Ruby < 2.3 support is not required anymore

Ref: #8530


NOTE: there is also an (unsafe) cop to detect this use case

https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Style/SafeNavigation

there are a few more occurrences

@codecov
Copy link

codecov bot commented Nov 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.11%. Comparing base (006abfc) to head (4d4a513).
Report is 10 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8533   +/-   ##
=======================================
  Coverage   99.11%   99.11%           
=======================================
  Files         141      141           
  Lines        4076     4076           
=======================================
  Hits         4040     4040           
  Misses         36       36           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tagliala tagliala force-pushed the chore/use-safe-navigation-operator-in-layout-helper branch from 8aaabf2 to 9d3dd04 Compare November 2, 2024 21:56
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
@tagliala tagliala force-pushed the chore/use-safe-navigation-operator-in-layout-helper branch from 9d3dd04 to 4d4a513 Compare November 2, 2024 22:00
Copy link
Member

@javierjulio javierjulio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tagliala tagliala merged commit 25a6b36 into master Nov 7, 2024
@tagliala tagliala deleted the chore/use-safe-navigation-operator-in-layout-helper branch November 7, 2024 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants