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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.x] Fix TextEdit color_region_cache bug #74777

Merged
merged 1 commit into from Mar 12, 2023

Conversation

lawnjelly
Copy link
Member

@lawnjelly lawnjelly commented Mar 11, 2023

Due to a single error, _is_line_in_region was previously iterating over the color highlighting for the entire document repeatedly for each line in the script.

This is now fixed, which should make the editor much faster with large scripts.

Explanation

The loop is meant to find the first line that is in the cache, but due to the error, it repeatedly checks whether the same line is in the cache, so it never breaks, and always reaches the beginning, so previous_line is incorrect throughout the rest of the routine.

Partially fixes #74733

Notes

This bug was really bad for performance - debug logging revealed that for each line of script the syntax highlighter evaluated every previous line, each time, so the performance drop was with the square of the number of lines, something like that.
i.e.

_is_line_in_region(5)
... evaluates 0, 1, 2, 3, 4
_is_line_in_region(6)
... evaluates 0, 1, 2, 3, 4 AGAIN and then 5
etc etc

Due to a single error, _is_line_in_region was previously iterating over the color highlighting for the entire document repeatedly for each line in the script.

This is now fixed, which should make the editor much faster with large scripts.
@lawnjelly lawnjelly requested a review from a team as a code owner March 11, 2023 16:25
@lawnjelly lawnjelly added bug topic:editor performance cherrypick:3.5 Considered for cherry-picking into a future 3.5.x release labels Mar 11, 2023
@lawnjelly lawnjelly added this to the 3.6 milestone Mar 11, 2023
@lawnjelly lawnjelly changed the title Fix TextEdit color_region_cache bug [3.x] Fix TextEdit color_region_cache bug Mar 11, 2023
@akien-mga akien-mga merged commit 16df341 into godotengine:3.x Mar 12, 2023
13 checks passed
@akien-mga
Copy link
Member

Thanks!

@lawnjelly lawnjelly deleted the textedit_lineinregion branch March 12, 2023 15:19
@akien-mga akien-mga changed the title [3.x] Fix TextEdit color_region_cache bug [3.x] Fix TextEdit color_region_cache bug Aug 18, 2023
@akien-mga
Copy link
Member

Cherry-picked for 3.5.3.

@akien-mga akien-mga removed the cherrypick:3.5 Considered for cherry-picking into a future 3.5.x release label Aug 18, 2023
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.

None yet

2 participants