Merge pull request #80809 from jsjtxietian/early-quit-in-_get_column_pos_of_word

Edit early in `TextEdit::_get_column_pos_of_word` to improve highlight performace
This commit is contained in:
Rémi Verschelde 2023-08-21 08:25:26 +02:00
commit 76a4b5d710
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 5 additions and 0 deletions

View File

@ -7000,6 +7000,11 @@ int TextEdit::_get_column_pos_of_word(const String &p_key, const String &p_searc
col = p_search.findn(p_key, p_from_column); col = p_search.findn(p_key, p_from_column);
} }
// If not found, just break early to improve performance.
if (col == -1) {
break;
}
// Whole words only. // Whole words only.
if (col != -1 && p_search_flags & SEARCH_WHOLE_WORDS) { if (col != -1 && p_search_flags & SEARCH_WHOLE_WORDS) {
p_from_column = col; p_from_column = col;