node icon indicating copy to clipboard operation
node copied to clipboard

src: modernize likely/unlikely hints

Open anonrig opened this issue 1 year ago • 4 comments

An attempt to modernize C++ code to use [[likely]] and [[unlikely]] available after C++20.

Reference: https://en.cppreference.com/w/cpp/language/attributes/likely

This pull-request also disables readability/braces rule from cpplint, since it doesn't support C++20. Main branch of cpplint supports it, but unfortunately they didn't release a new version in the last 2 years.

anonrig avatar Sep 28 '24 17:09 anonrig

Review requested:

  • [ ] @nodejs/crypto
  • [ ] @nodejs/http2
  • [ ] @nodejs/net
  • [ ] @nodejs/startup

nodejs-github-bot avatar Sep 28 '24 17:09 nodejs-github-bot

cc @nodejs/cpp-reviewers

anonrig avatar Sep 28 '24 17:09 anonrig

CI: https://ci.nodejs.org/job/node-test-pull-request/62832/

nodejs-github-bot avatar Sep 28 '24 19:09 nodejs-github-bot

Codecov Report

Attention: Patch coverage is 34.59716% with 138 lines in your changes missing coverage. Please review.

Project coverage is 88.23%. Comparing base (3800d60) to head (0b257ca). Report is 23 commits behind head on main.

Files with missing lines Patch % Lines
src/crypto/crypto_tls.cc 15.38% 6 Missing and 16 partials :warning:
src/cares_wrap.cc 0.00% 8 Missing and 5 partials :warning:
src/quic/session.cc 0.00% 10 Missing :warning:
src/quic/packet.cc 0.00% 8 Missing :warning:
src/crypto/crypto_cipher.cc 0.00% 0 Missing and 7 partials :warning:
src/crypto/crypto_hash.cc 12.50% 0 Missing and 7 partials :warning:
src/node_http2.cc 63.15% 2 Missing and 5 partials :warning:
src/crypto/crypto_dh.cc 0.00% 0 Missing and 6 partials :warning:
src/crypto/crypto_sig.cc 28.57% 0 Missing and 5 partials :warning:
src/quic/endpoint.cc 0.00% 5 Missing :warning:
... and 25 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #55155      +/-   ##
==========================================
- Coverage   88.24%   88.23%   -0.02%     
==========================================
  Files         651      651              
  Lines      183937   183911      -26     
  Branches    35861    35833      -28     
==========================================
- Hits       162318   162274      -44     
- Misses      14911    14945      +34     
+ Partials     6708     6692      -16     
Files with missing lines Coverage Δ
src/api/callback.cc 78.10% <100.00%> (ø)
src/api/environment.cc 76.00% <100.00%> (-0.49%) :arrow_down:
src/base_object.cc 84.61% <100.00%> (-0.97%) :arrow_down:
src/crypto/crypto_keys.cc 73.06% <ø> (-0.35%) :arrow_down:
src/crypto/crypto_spkac.cc 88.88% <100.00%> (ø)
src/env-inl.h 96.80% <100.00%> (+<0.01%) :arrow_up:
src/env.cc 85.65% <100.00%> (+0.02%) :arrow_up:
src/node_contextify.cc 81.45% <100.00%> (+0.10%) :arrow_up:
src/node_modules.cc 78.64% <100.00%> (+0.53%) :arrow_up:
src/permission/permission.h 80.00% <100.00%> (+2.22%) :arrow_up:
... and 42 more

... and 15 files with indirect coverage changes

codecov[bot] avatar Sep 28 '24 19:09 codecov[bot]

Landed in 317d2450f94bd8d307e155cf4d50ca9fb02ba503

nodejs-github-bot avatar Sep 30 '24 18:09 nodejs-github-bot

We've recently released 2.0. Let us know if the [[(un)likely]] detection works!

aaronliu0130 avatar Oct 07 '24 21:10 aaronliu0130