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

Release flag and method are inefficient; operate by value instead #6

Closed
chris-morgan opened this issue Jun 1, 2017 · 1 comment
Closed

Comments

@chris-morgan
Copy link

It’d be more efficient to have release() consume self and return the PathBuf:

pub fn release(self) -> PathBuf {
    let path = mem::replace(&mut self.path, PathBuf::new());
    mem::forget(self);
    path
}

That way you don’t need to allocate twice just to get the path out as a PathBuf.

This also allows you to scrap the flag _release altogether.

@samgiles
Copy link
Owner

Version 0.4.0 does something like this now! Thanks for the suggestion.

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

No branches or pull requests

2 participants