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
Modernize/bitfield.cc: Make into C++ #1917
Conversation
…commented code too
Hey @kvakvs, I love these patches and want to make sure I'm understanding right: the description has a Either "this is a draft" or "this is ready" is fine; I just want to make sure I'm understanding right. |
For this particular PR these changes are desired but they will probably explode the line count in the diff. |
A loosely related question struct Bytes {
uint64_t bytes;
// and some arithmetic support + - > < etc
};
struct Bits {
uint64_t bits;
// and some arithmetic support + - > < etc
}; P.S. Clang is smart enough to treat these as simple |
At one point I was looking into using https://github.com/nholthaus/units in the Qt client; maybe it makes sense to look at it again for libtransmission as well. IIRC it's a header-only with no dependencies. If you're thinking about adding types for bits & bytes, maybe take a look at that and see what you think. |
The library looks interesting, but i am confused which storage type is used for |
How about use-defined literals, like how aria2 does it? |
tr_bitfield
becomesBitfield
, inner fields become private andsnake_case_
add
→setBit
,rem
→clearBit
,has
→readBit
etc. Old naming was catering to the bitfield usage (as a storage of torrent blocks), new naming is neutral.TODO:
byte*
to avector
orunique_ptr