Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: remove unnecessary optional chaining #55728

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gurgunday
Copy link
Contributor

From the V8 blog:

Still, be considerate about using more than one optional chaining operator in a single chain. If a value is guaranteed to not be nullish, then using ?. to access properties on it is discouraged.

It adds more bytecode to each property access, in all these cases we know that the variables are not nullish

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Nov 5, 2024
Copy link

codecov bot commented Nov 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.39%. Comparing base (58a7b00) to head (cb499ae).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #55728      +/-   ##
==========================================
- Coverage   88.40%   88.39%   -0.01%     
==========================================
  Files         654      654              
  Lines      187655   187655              
  Branches    36111    36112       +1     
==========================================
- Hits       165889   165881       -8     
- Misses      14996    15003       +7     
- Partials     6770     6771       +1     
Files with missing lines Coverage Δ
lib/events.js 99.75% <100.00%> (ø)
lib/fs.js 98.14% <100.00%> (ø)
lib/internal/fs/promises.js 98.24% <100.00%> (ø)
lib/internal/fs/read/context.js 94.57% <100.00%> (ø)
lib/internal/fs/watchers.js 85.78% <100.00%> (ø)
lib/timers/promises.js 99.15% <100.00%> (ø)

... and 20 files with indirect coverage changes

@anonrig anonrig added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Nov 5, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 5, 2024
@nodejs-github-bot
Copy link
Collaborator

Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

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

I wonder if we could have a lint rule for that, that'd be neat

@nodejs-github-bot
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants