Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Use const functions where possible#684

Merged
VictorKoenders merged 1 commit intobincode-org:trunkfrom
richardpringle:const-fns
Dec 14, 2023
Merged

Use const functions where possible#684
VictorKoenders merged 1 commit intobincode-org:trunkfrom
richardpringle:const-fns

Conversation

@richardpringle
Copy link
Contributor

I just used clippy for this. I actually assume that you will not want the brunt of this change but I figured it was easier to make the change everywhere then simply pick the ones you deem acceptable (if any).

I definitey think some of the constructors should be const.

Thanks in advance!

@VictorKoenders
Copy link
Contributor

Looks good to me.

Out of pure interest, can you check if this actually improves any of the benchmarks?

@codecov
Copy link

codecov bot commented Dec 14, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (ff7a45a) 57.24% compared to head (4a77a75) 57.24%.

Files Patch % Lines
src/error.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            trunk     #684   +/-   ##
=======================================
  Coverage   57.24%   57.24%           
=======================================
  Files          51       51           
  Lines        4350     4350           
=======================================
  Hits         2490     2490           
  Misses       1860     1860           

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

@VictorKoenders VictorKoenders merged commit 3a638a7 into bincode-org:trunk Dec 14, 2023
@richardpringle
Copy link
Contributor Author

Looks good to me.

Out of pure interest, can you check if this actually improves any of the benchmarks?

I'm not quite sure I understand what you're asking. const shouldn't change the behaviour at all, it will only make those functions available in const context. In order to improve a benchmark, you would have to change the code at the call-site.

You should also be aware that removing const from a pub const function is a breaking change. Given the extensive use of the builder-pattern, this shouldn't be a concern, though.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants