Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoding/Encoding for []uint16, []uint32 and []uint64 #84

Merged
merged 3 commits into from
Apr 4, 2024

Conversation

poszu
Copy link
Collaborator

@poszu poszu commented Mar 29, 2024

No description provided.

@poszu poszu requested a review from dshulyak March 29, 2024 16:40
Copy link

codecov bot commented Mar 29, 2024

Codecov Report

Attention: Patch coverage is 66.30435% with 31 lines in your changes are missing coverage. Please review.

Project coverage is 46.4%. Comparing base (236def4) to head (52a4646).

Files Patch % Lines
decoder.go 62.5% 9 Missing and 9 partials ⚠️
encoder.go 66.6% 6 Missing and 6 partials ⚠️
generate.go 87.5% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master     #84     +/-   ##
========================================
+ Coverage    41.8%   46.4%   +4.6%     
========================================
  Files           6       6             
  Lines         720     811     +91     
========================================
+ Hits          301     377     +76     
+ Misses        384     378      -6     
- Partials       35      56     +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@poszu poszu requested a review from fasmat March 29, 2024 17:00
encoder.go Outdated
}
for _, v := range value {
scratch := e.scratch[:2]
binary.LittleEndian.PutUint16(scratch, v)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this module defaults to compact form for all unsigned integers. if you want to have non-compact form, in golang tags seems like the best approach e.g.

type Struct struct {
     Noncompact uint64 `scale:"noncompact"`
     NoncompactSlice []uint64 `scale:"noncompact"`
}

also noncompact name is not nice, maybe full is better

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I changed the functions to encode values in compact form. I don't need the full form now so I will leave implementing the full/noncompact tag for the future.

generate.go Outdated Show resolved Hide resolved
@poszu poszu requested a review from dshulyak March 30, 2024 08:40
@poszu poszu merged commit 34c1f26 into master Apr 4, 2024
10 checks passed
@poszu poszu deleted the encoding-uintX-slices branch April 4, 2024 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants