fix: use Buffer.concat on node as it is faster#73
Merged
achingbrain merged 1 commit intomasterfrom Nov 24, 2023
Merged
Conversation
Running the concat.js benchmark: Before: ``` Uint8Arrays.concat x 792,619 ops/sec ±0.67% (98 runs sampled) Uint8Arrays.concat with length x 782,264 ops/sec ±0.18% (98 runs sampled) Uint8Array.set x 799,528 ops/sec ±0.67% (92 runs sampled) allocUnsafe.set x 851,403 ops/sec ±0.24% (97 runs sampled) Fastest is allocUnsafe.set ``` After: ``` Uint8Arrays.concat x 896,831 ops/sec ±0.20% (101 runs sampled) Uint8Arrays.concat with length x 887,523 ops/sec ±0.19% (99 runs sampled) Uint8Array.set x 814,749 ops/sec ±0.46% (98 runs sampled) allocUnsafe.set x 885,140 ops/sec ±0.28% (98 runs sampled) Fastest is Uint8Arrays.concat ```
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #73 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 16 16
Lines 554 547 -7
Branches 93 82 -11
=========================================
- Hits 554 547 -7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
github-actions bot
pushed a commit
that referenced
this pull request
Nov 24, 2023
## [4.0.9](v4.0.8...v4.0.9) (2023-11-24) ### Bug Fixes * use Buffer.concat on node as it is faster ([#73](#73)) ([8d6c24b](8d6c24b))
shamilovtim
reviewed
Dec 7, 2023
| export function concat (arrays: Array<ArrayLike<number>>, length?: number): Uint8Array { | ||
| export function concat (arrays: Uint8Array[], length?: number): Uint8Array { | ||
| if (globalThis.Buffer != null) { | ||
| return asUint8Array(globalThis.Buffer.concat(arrays, length)) |
There was a problem hiding this comment.
Unfortunately arrays here causes Buffer.concat to throw, where before arrays would have been converted to a Uint8Array on line 24.
achingbrain
added a commit
that referenced
this pull request
Dec 7, 2023
Reinstantes the performance changes from #73 BREAKING CHANGE: concat now expects an array of Uint8Arrays
achingbrain
added a commit
that referenced
this pull request
Dec 7, 2023
Reinstates the performance changes from #73 BREAKING CHANGE: concat now expects an array of Uint8Arrays
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Running the concat.js benchmark:
Before:
After: