Fixes a text find perf issue, if can't find any

match words, just early break the while loop. This
will improve a lot when p_search.length is way too
long since p_from_column will only plus 1 every loop
This commit is contained in:
jsjtxietian 2023-08-20 16:49:16 +08:00
parent 5444afae63
commit 70dad7e5a3

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);
}
// If not found, just break early to improve performance.
if (col == -1) {
break;
}
// Whole words only.
if (col != -1 && p_search_flags & SEARCH_WHOLE_WORDS) {
p_from_column = col;