Skip to content

buffer: use constexpr where possible #58141

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

Merged
merged 1 commit into from
May 6, 2025

Conversation

anonrig
Copy link
Member

@anonrig anonrig commented May 3, 2025

Self-explanatory cc @nodejs/buffer

@anonrig anonrig requested review from jasnell and ronag May 3, 2025 16:48
@nodejs-github-bot nodejs-github-bot added buffer Issues and PRs related to the buffer subsystem. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels May 3, 2025
Copy link

codecov bot commented May 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.18%. Comparing base (723d7bb) to head (6577341).
Report is 28 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #58141   +/-   ##
=======================================
  Coverage   90.17%   90.18%           
=======================================
  Files         630      630           
  Lines      186473   186473           
  Branches    36613    36615    +2     
=======================================
+ Hits       168160   168166    +6     
+ Misses      11128    11119    -9     
- Partials     7185     7188    +3     
Files with missing lines Coverage Δ
src/node_buffer.cc 69.09% <ø> (ø)

... and 31 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@anonrig anonrig requested a review from mcollina May 3, 2025 18:02
@targos
Copy link
Member

targos commented May 3, 2025

Just for my education, does it really change the assembly emitted by compilers. This seems trivial to optimize but I don't know much about it 🙈

@anonrig
Copy link
Member Author

anonrig commented May 3, 2025

Just for my education, does it really change the assembly emitted by compilers. This seems trivial to optimize but I don't know much about it 🙈

Yes. The if statement that checks for these conditions will not be evaluated on runtime, but rather on compile time. Since this parameter is a template argument, we can make it a constexpr.

@anonrig anonrig added the request-ci Add this label to start a Jenkins CI on a PR. label May 3, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label May 3, 2025
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@anonrig anonrig added the commit-queue Add this label to land a pull request using GitHub Actions. label May 6, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label May 6, 2025
@nodejs-github-bot nodejs-github-bot merged commit 2c36ffe into nodejs:main May 6, 2025
73 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 2c36ffe

targos pushed a commit that referenced this pull request May 16, 2025
PR-URL: #58141
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
aduh95 pushed a commit that referenced this pull request Jun 10, 2025
PR-URL: #58141
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
buffer Issues and PRs related to the buffer subsystem. c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants