robinm

joined 2 years ago
[–] robinm@programming.dev 1 points 2 years ago* (last edited 2 years ago)

And cgdb is kind of the same but with better controls and syntax coloration.

[–] robinm@programming.dev 1 points 2 years ago* (last edited 2 years ago)

That's totally right but I thought you were talking about signed numbers since you said “integer overflow”. I forgot that len is usually unsigned in C++.

[–] robinm@programming.dev 1 points 2 years ago

emplace controls the construction of the object added to the collection. It's also important but not related to the problem exposed by OP which is “how to remove the capacity check when we know statically that there is enough space”.

[–] robinm@programming.dev 1 points 2 years ago

I use win+arrow key quite a lot too.

[–] robinm@programming.dev 1 points 2 years ago (2 children)

In C++ integer overflow is UB so this edge case cannot exist

[–] robinm@programming.dev 6 points 2 years ago (6 children)

Couldn't this be solved by having push_back being an inline function (or at least the check on capacity being inlined and the rest of the non-trivial part being in a sub non-inline function)?

[–] robinm@programming.dev 3 points 2 years ago

There are 2 metrics that need to be considered:

  • easy to read
  • easy to modify

The first point is by far the most important. Usually DRY win because less code means less to read so less to put in your head. But if the abstraction is too complicated (for example because there are two many parameteres) then it's worth considering drying.

And don't forget the second point, but do not overthing and YAGNI. Sometime a simple comment “don't forget to update method foobar()” is enough. Don't forget either that you can always rewrite the abstraction when you need to modify something (if the original did not fit your new requirements), but for this to be an easy task, the understanding of the original abstraction must be crystal clear. That's why the first point is so important.

[–] robinm@programming.dev 6 points 2 years ago

And you should not forget that Emacs is way harder when you are 4 because your hands are smaller!

[–] robinm@programming.dev 3 points 2 years ago

It's also quite opinated (which I consider a good thing) so that what the author of lib.rs considers relevant crates are shown first.

view more: ‹ prev next ›