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

Avoid cloning filename in threads communications #16

Open
yammmt opened this issue Sep 12, 2020 · 0 comments
Open

Avoid cloning filename in threads communications #16

yammmt opened this issue Sep 12, 2020 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@yammmt
Copy link
Owner

yammmt commented Sep 12, 2020

Current code uses clone() method to send Pathbuf.

slide-show-rs/src/main.rs

Lines 291 to 293 in ac564d3

tx_to_buf_func
.send(ThreadMessage::Filepath(img_filepaths[img_idx].clone()))
.unwrap();

Here, it's better to use &'static lifetime to avoid running the clone() method. The clone() method could take a long time if its contents, here, the given file path is an incredible long.

The main thread must have the file path array as long as the program runs: its lifetime is &'static. And it's the reason why I couldn't use move.

@yammmt yammmt added the enhancement New feature or request label Sep 12, 2020
@yammmt yammmt self-assigned this Sep 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant