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

Replace find with contains/has where applicable #91619

Merged
merged 1 commit into from
May 8, 2024

Conversation

AThousandShips
Copy link
Member

@AThousandShips AThousandShips commented May 6, 2024

  • Replaces find(...) != -1, find(...) > -1, find(...) >= 0 with contains for String
  • Replaces find(...) == -1, find(...) < 0 with !contains for String
  • Replaces find(...) != -1, find(...) > -1, find(...) >= 0 with has for containers
  • Replaces find(...) == -1, find(...) < 0 with !has for containers

Split into four commits for review to make it easier to compare each type, to check the replacements are appropriate

@AThousandShips AThousandShips added this to the 4.x milestone May 6, 2024
@AThousandShips AThousandShips requested review from a team as code owners May 6, 2024 14:39
@AThousandShips AThousandShips changed the title Replace find with contains/has where applicable Replace find with contains/has where applicable May 6, 2024
@AThousandShips AThousandShips requested review from a team as code owners May 6, 2024 16:28
@Chaosus
Copy link
Member

Chaosus commented May 6, 2024

Guess this line could be changed too (after d8aa2c6):

if (!p_search_string.is_empty() && mi.name.findn(p_search_string) == -1) {

@AThousandShips
Copy link
Member Author

That's findn that's different, that's covered here:

Copy link
Contributor

@Riteo Riteo left a comment

Choose a reason for hiding this comment

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

The diff looks fine and I really appreciate this change!

Thanks for splitting the patch, it really helped with reviewing as I could go in full pattern-matching mode with the word diff.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

Also looks good to me. I guess we can squash before merge now that it's been reviewed.

@akien-mga akien-mga modified the milestones: 4.x, 4.3 May 8, 2024
* Replaces `find(...) != -1` with `contains` for `String`
* Replaces `find(...) == -1` with `!contains` for `String`
* Replaces `find(...) != -1` with `has` for containers
* Replaces `find(...) == -1` with `!has` for containers
Copy link
Member

@mhilbrunner mhilbrunner left a comment

Choose a reason for hiding this comment

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

Thank you so much! Spotted nothing.

@akien-mga akien-mga merged commit a9a1d0a into godotengine:master May 8, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@AThousandShips AThousandShips deleted the find_improve branch May 8, 2024 13:59
@AThousandShips
Copy link
Member Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants