Switch from recursion to iterative for backfilling colour regions

This commit is contained in:
Paulb23 2020-10-03 14:56:13 +01:00
parent 9b1c9cef17
commit ee4a1c99a7
2 changed files with 14 additions and 0 deletions

View File

@ -73,6 +73,13 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting(int p_line)
color_region_cache[p_line] = -1;
int in_region = -1;
if (p_line != 0) {
int prev_region_line = p_line - 1;
while (prev_region_line > 0 && !color_region_cache.has(prev_region_line)) {
prev_region_line--;
}
for (int i = prev_region_line; i < p_line - 1; i++) {
get_line_syntax_highlighting(i);
}
if (!color_region_cache.has(p_line - 1)) {
get_line_syntax_highlighting(p_line - 1);
}

View File

@ -149,6 +149,13 @@ Dictionary CodeHighlighter::_get_line_syntax_highlighting(int p_line) {
color_region_cache[p_line] = -1;
int in_region = -1;
if (p_line != 0) {
int prev_region_line = p_line - 1;
while (prev_region_line > 0 && !color_region_cache.has(prev_region_line)) {
prev_region_line--;
}
for (int i = prev_region_line; i < p_line - 1; i++) {
get_line_syntax_highlighting(i);
}
if (!color_region_cache.has(p_line - 1)) {
get_line_syntax_highlighting(p_line - 1);
}