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.
Flatbuffers supports creating byte vectors from native byte objects in some languages (e.g., Go, Python, Swift, Java).
This PR brings
createByteVector
to TypeScript, which is similar tocreateString
except it does not add the null terminator and does not require UTF-8 encoded data.Also, the performance for
createString
method could be improved (see below) if instead of using for loop we useset
, since the buffer is a Uint8Array. Larger gains can be seen when creating large byte vectors. Set is used also here, so the change would not break any previous compatibility requirements.Here is a gist with the benchmarking code. I used node v18.16.1.
Results before the change:
Results after the change: