Title: lib: use fastbuffer for empty buffer allocation by gurgunday · Pull Request #60558 · nodejs/node · GitHub
Open Graph Title: lib: use fastbuffer for empty buffer allocation by gurgunday · Pull Request #60558 · nodejs/node
X Title: lib: use fastbuffer for empty buffer allocation by gurgunday · Pull Request #60558 · nodejs/node
Description: As in other places, we don't need to call Buffer.alloc(0), which validates the length and calls FastBuffer anyway, when we're creating an empty Buffer This bypasses the validation logic and is consequently faster buffers/fast-buffer.js buffers/fast-buffer.js operation="fastbuffer" n=1000000: 47,834,970.118450865 buffers/fast-buffer.js operation="bufferalloc" n=1000000: 33,173,868.757805813 'use strict'; // flags: --expose-internals const common = require('../common'); const { FastBuffer } = require('internal/buffer'); const bench = common.createBenchmark(main, { n: [1e6], operation: ['fastbuffer', 'bufferalloc'], }); function main({ n, operation }) { switch (operation) { case 'fastbuffer': bench.start(); for (let i = 0; i < n; i++) { new FastBuffer() } bench.end(n); break; case 'bufferalloc': bench.start(); for (let i = 0; i < n; i++) { Buffer.alloc(0) } bench.end(n); break; } }
Open Graph Description: As in other places, we don't need to call Buffer.alloc(0), which validates the length and calls FastBuffer anyway, when we're creating an empty Buffer This bypasses the validation logic and...
X Description: As in other places, we don't need to call Buffer.alloc(0), which validates the length and calls FastBuffer anyway, when we're creating an empty Buffer This bypasses the validation l...
Opengraph URL: https://github.com/nodejs/node/pull/60558
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:fa82978a-70ea-d7b6-3fc8-af5b3640513e |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 98EA:127DAD:B92E83:F7375A:6A4C531F |
| html-safe-nonce | 59ccf787939f9f00927261bc4fd7545cd027d9c822501587672f7006c402f42b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OEVBOjEyN0RBRDpCOTJFODM6RjczNzVBOjZBNEM1MzFGIiwidmlzaXRvcl9pZCI6IjIxNjkxNzI1NDc0MzM0MTk1NTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b784ac720dca0cf15ed28e2d01c6b7cb6e2335e9d8f17be8fbc71e3c18892e77 |
| hovercard-subject-tag | pull_request:2970987823 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/nodejs/node/pull/60558/files |
| twitter:image | https://avatars.githubusercontent.com/u/74139498?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/74139498?s=400&v=4 |
| og:image:alt | As in other places, we don't need to call Buffer.alloc(0), which validates the length and calls FastBuffer anyway, when we're creating an empty Buffer This bypasses the validation logic and... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3d11bb817438277de2a940854450e83a7d32b6aeb5014e9e6b00a6423900251c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 14099438da5379150f15a2892474c7c7e6c0e55e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width