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

cache refactor #12

Merged
merged 4 commits into from
Aug 26, 2020
Merged

cache refactor #12

merged 4 commits into from
Aug 26, 2020

Conversation

mlvzk
Copy link
Owner

@mlvzk mlvzk commented Aug 26, 2020

No description provided.

);

load_source_and_add(
std::fs::read(&options_nixos_cache_path).map(|c| OptionsDatabase::load(&c)),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't we use and_then here to flatten the error structure beforehand? the Errors type should be able to represent that possible io error, shouldn't it?

Ok(true)
}
}
impl Cache for CommentsDatabase {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would ofc be prettier as a #[derive(Cache)] macro, although those are kind of annoying to implement. Generally something to keep in mind, but i don't think we need to necessarily do that now

let new_keys = gen_keys()?;
let last = std::mem::replace(&mut self.keys, new_keys);

Ok(last != self.keys)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally i see the point in having update return information about if anything actually changed, but in cases like this, doing that check might actually have some performance implications (as it probably needs to iterate over all of the values pretty much, "undoing" the efficiency you've saved by doing the std::mem::replace. Are you sure that we actually need that return information, or that this causes no noticable increase in update-times?

@elkowar
Copy link
Collaborator

elkowar commented Aug 26, 2020

Added a few comments, i think that's all I've noticed. everything else looks perfect!

@mlvzk mlvzk merged commit d048474 into master Aug 26, 2020
mrcjkb pushed a commit to mrcjkb/manix that referenced this pull request Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants