keepass-diff
keepass-diff copied to clipboard
refactor code
While debugging a problem (which turns out to be caused by my password manager) I just started to refactor the code to make it easier to read and understand. The main changes are:
- replace custom
Stackbystd::vec::Vec - make fields private and use constructors for costruction of types
- make more use of iterator adapters
- apply lints
Not sure if you want any of those changes. In case you only want some of them I can also revert the others.
Sorry for not getting back to this. I've only had time to skim over the changes as there was lots of private and work related stuff going on. There are lots of nice improvements regarding the code and where I obviously didn't know about some functions or how to do it properly with Rust. I definitely want to understand what has been changed and incorporate things like this into the code. It's a bit much for one PR, so I have postponed properly checking it for forever. I hope in a few weeks from now I have more time for this project here again and will be able to get this code base and everything around it more polished into something that can be downloaded and used.
I am also working on similar changes using cargo clippy but I for now am trying not to touch main.rs as I believe there should be a bigger refactor on execution flow and maybe replace some variable declarations. Good examples would be:
- Replace
Stringin favor ofBox<str>as the former is a struct that is approximatelyusize * 3(pointer + current length + capacity) and the latter is just a fat pointer (pointer + len). Also after initial command line read, the variables are no longer mutated so we don't methods for extending the allocation. - Find a way to less data cloning and use more referencing as each clone op is
O(n)wherenis equal to password length.