-
Notifications
You must be signed in to change notification settings - Fork 1
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
waddy: case insensitive search bar #18
Conversation
src/gui/programs/waddy.rs
Outdated
self.instances[instance_index] | ||
.search | ||
.text | ||
.to_lowercase() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull the whole self.instances[instance_index].search.text.lowercase()
outside of the loop so that it is not calculated many times over.
src/gui/programs/waddy.rs
Outdated
let search_text = if is_search_enabled { | ||
self.instances[instance_index].search.text.to_lowercase() | ||
} else { | ||
String::new() | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be redundant. Just convert to lowercase without any conditions. Search text always have a valid string and empty string is a valid string.
src/gui/programs/waddy.rs
Outdated
// split into two steps because of rust | ||
let filtered_tiles = (0..count) | ||
.filter(|&texture_tile| { | ||
if is_search_enabled { | ||
if is_search_enabled && !search_text.is_empty() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to add this condition
Thanks |
there is probably a better and optimal way to do this, but it works