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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize SceneTree's change_scene_to_file autocompletion #87197

Conversation

Mickeon
Copy link
Contributor

@Mickeon Mickeon commented Jan 15, 2024

As is currently, the autocompletion for the SceneTree's change_scene_to_file is handled within get_argument_options. The implementation is done using a DirAccess and iterating through every file recursively, every time. It turns out this has a few problems:

  • It is EXTREMELY slow, especially on larger projects.
    • At least on my machine, I have definitely seen it struggle.
  • It does not account for the way files are imported.
    • Only file extensions are checked. This is not enough because a PackedScene could be imported in other ways, as well (such as .glb files).
  • It does not respect the user's "text_editor/completion/complete_file_paths" Editor Setting.
  • It's not scalable. This is not the only method that would benefit from file path autocompletion

This PR moves the autocompletion code out of the SceneTree and into the autocompletion code itself, recycling an existing function to go around all imported PackedScenes. This uses of the editor's own EditorFileSystem and is overall more performant.

In the future, this code snippet can even be further expanded with other similar methods.

@Mickeon Mickeon requested review from a team as code owners January 15, 2024 00:31
@Mickeon Mickeon force-pushed the autocompletion-SceneTree-change-packed-to-file branch from 14d2e8d to 4d1309e Compare January 15, 2024 00:33
@Calinou Calinou added this to the 4.x milestone Jan 15, 2024
@Mickeon Mickeon force-pushed the autocompletion-SceneTree-change-packed-to-file branch from 4d1309e to b1bf016 Compare February 26, 2024 15:27
@Mickeon Mickeon force-pushed the autocompletion-SceneTree-change-packed-to-file branch from b1bf016 to ba3dbd9 Compare February 29, 2024 20:03
@Mickeon Mickeon requested a review from KoBeWi February 29, 2024 20:09
Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested in my project with 1000+ scenes and this makes a nice speedup.

@akien-mga akien-mga modified the milestones: 4.x, 4.3 Feb 29, 2024
@akien-mga
Copy link
Member

Needs a rebase.

@Mickeon Mickeon force-pushed the autocompletion-SceneTree-change-packed-to-file branch 2 times, most recently from c7d5212 to f1a41f9 Compare March 1, 2024 14:08
@Mickeon
Copy link
Contributor Author

Mickeon commented Mar 1, 2024

All good now

modules/gdscript/gdscript_editor.cpp Outdated Show resolved Hide resolved
modules/gdscript/gdscript_editor.cpp Outdated Show resolved Hide resolved
@Mickeon Mickeon force-pushed the autocompletion-SceneTree-change-packed-to-file branch from f1a41f9 to 7b3e1a5 Compare March 1, 2024 14:12
@Mickeon
Copy link
Contributor Author

Mickeon commented Mar 1, 2024

All gooder now.

@akien-mga akien-mga merged commit 8c0511a into godotengine:master Mar 1, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@Mickeon Mickeon deleted the autocompletion-SceneTree-change-packed-to-file branch March 1, 2024 16:40
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.

6 participants