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

Switch to C++ and modernize code? #87

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft

Conversation

vlolteanu
Copy link

I've played around a bit with the code just for the hell of it. I see multiple avenues for improvement if we switch to C++. However, with all the already-open PRs (and the potential for conflicts), I'm not sure if any of this will make it in, so I'm leaving it as a draft.

Anyway...

  • Manual memory management can be done away with almost entirely.
  • I see what looks like a home-brewed RB tree. And a list. And Boyer Moor. This stuff can be replaced with implementations from STL. (BM is replaced in this PR.)
  • All of the hoop-jumping to resolve paths properly can be handled by std::filesystem
  • The way error handling is done is extremely tedious. There is a lot of duplicate code with checks to the err variable on almost every line. Consolidating stuff into functions and introducing exceptions would make it a lot easier to read.
  • How reads and writes are used (not reading the full amount == error) is fundamentally flawed (but works in practice). You're not guaranteed to read the full amount, and you may even get EAGAIN or EINTR. These cases are benign; you just have to read/write the remainder.

All in all, I'd say a lot of code could be trimmed by switching to C++. I know my proposal throws a wrench in what you've got going, so it's no problem if you don't accept it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant