From be0eba0f75d775295d830f122ca954953db9de4c Mon Sep 17 00:00:00 2001 From: Maganty Rushyendra Date: Fri, 12 Jun 2020 17:28:43 +0800 Subject: [PATCH] Fix whole word search slowdown in editor Reduce repeated iteration through the full text when counting the number of occurrences of whole words while searching a file in the editor. (cherry picked from commit 2433287871ec5ccdf1f85e3e9c057a1a589d3848) --- editor/code_editor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index ffe5ee88316..4416a1681fd 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -320,7 +320,7 @@ void FindReplaceBar::_update_results_count() { if (pos == -1) break; if (is_whole_words()) { - from_pos++; // Making sure we won't hit the same match next time, if we get out via a continue. + from_pos = pos + 1; // Making sure we won't hit the same match next time, if we get out via a continue. if (pos > 0 && !is_symbol(full_text[pos - 1])) continue; if (pos + searched.length() < full_text.length() && !is_symbol(full_text[pos + searched.length()]))