Skip to content

Conversation

@gurgunday
Copy link
Member

As in other places here, we don't need to call Buffer.alloc(0), which validates the length and calls FastBuffer anyway

This bypasses the validation logic and is consequently faster

@nodejs-github-bot nodejs-github-bot added buffer Issues and PRs related to the buffer subsystem. needs-ci PRs that need a full CI run. labels Oct 24, 2025
@gurgunday gurgunday added the performance Issues and PRs related to the performance of Node.js. label Oct 24, 2025
@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.58%. Comparing base (d9cf867) to head (e12c1a8).
⚠️ Report is 49 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #60398      +/-   ##
==========================================
- Coverage   88.58%   88.58%   -0.01%     
==========================================
  Files         704      704              
  Lines      207815   207815              
  Branches    40036    40041       +5     
==========================================
- Hits       184102   184083      -19     
- Misses      15758    15770      +12     
- Partials     7955     7962       +7     
Files with missing lines Coverage Δ
lib/buffer.js 100.00% <100.00%> (ø)

... and 39 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.

@gurgunday gurgunday changed the title buffer: retun fastbuffer directly instead of buffer.alloc(0) buffer: return fastbuffer directly instead of buffer.alloc(0) Oct 27, 2025
@ChALkeR
Copy link
Member

ChALkeR commented Oct 27, 2025

Perhaps you also want to replace Buffer.allocUnsafe(0) likewise

@gurgunday
Copy link
Member Author

gurgunday commented Nov 2, 2025

Closed in favor of #60558

@gurgunday gurgunday closed this Nov 2, 2025
@ChALkeR
Copy link
Member

ChALkeR commented Nov 2, 2025

@gurgunday why not though?

@gurgunday
Copy link
Member Author

Didn't you see my comment?

Closed in favor of #60558

@ChALkeR
Copy link
Member

ChALkeR commented Nov 2, 2025

@gurgunday I mean the thumbs down on

Perhaps you also want to replace Buffer.allocUnsafe(0) likewise

Which I interpreted as "No", but curious why (which is why I asked)

@gurgunday
Copy link
Member Author

Oh, sorry - I only saw one instance of that and it's allocated once during bootstrap

@ChALkeR
Copy link
Member

ChALkeR commented Nov 2, 2025

Ah, the rest are in undici, where this wouldn't be possible directly, I see...
Thanks!

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. needs-ci PRs that need a full CI run. performance Issues and PRs related to the performance of Node.js.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants