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

waddy: case insensitive search bar #18

Merged
merged 4 commits into from
Sep 21, 2024
Merged

Conversation

G2Pavon
Copy link
Contributor

@G2Pavon G2Pavon commented Sep 21, 2024

there is probably a better and optimal way to do this, but it works

self.instances[instance_index]
.search
.text
.to_lowercase()
Copy link
Owner

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.

Comment on lines 545 to 549
let search_text = if is_search_enabled {
self.instances[instance_index].search.text.to_lowercase()
} else {
String::new()
};
Copy link
Owner

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.

// 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() {
Copy link
Owner

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

@khanghugo
Copy link
Owner

Thanks

@khanghugo khanghugo merged commit bc449a6 into khanghugo:master Sep 21, 2024
4 checks passed
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