protocolbuffers / protocolbuffers/protobuf-javascript
Using JS typed arrays in JoinFloat
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 471
- Forks
- 91
- Avg merge
- 3h 57m
- Merged PRs (30d)
- 2
Description
Hi,
Has anyone thought of using JS typed arrays in the splitFloat and joinFloat methods for the JavaScript library (https://github.com/google/protobuf/blob/master/js/binary/utils.js#L388)?
One could imagine adding something like:
jspb.utils.joinFloat64 = function(bitsLow, bitsHigh) {
if (window.Uint32Array) {
bytes = Uint8Array.of(bitsLow, bitsHigh)
data = new Float64Array(bytes.buffer)
return data[0];
}
// ...
}
And vica-versa for the splitFloat method. This might increase readability (and depending on if it taps into the JS engine's native implementation, maybe even speed).
Happy to write the PR, just curious if it would be useful / appreciated!
Let me know,
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in js/binary/utils.js around line 388 and read the splitFloat and joinFloat implementations and their surrounding compatibility logic. Evaluate whether typed arrays can be used there without losing the existing fallback behavior; the work is done when both methods remain correct across supported environments and the change is ready for review.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100