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

Fix inefficient list iteration in Node #88785

Merged
merged 1 commit into from
Feb 25, 2024

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Feb 24, 2024

Noticed some random code that iterates a List using indices.

@KoBeWi KoBeWi added this to the 4.3 milestone Feb 24, 2024
@KoBeWi KoBeWi requested a review from a team as a code owner February 24, 2024 22:20
Copy link
Contributor

@Mickeon Mickeon left a comment

Choose a reason for hiding this comment

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

So that's more efficient, huh?

Even if it weren't, this is standard across the codebase.

@KoBeWi
Copy link
Member Author

KoBeWi commented Feb 25, 2024

So that's more efficient, huh?

It's more efficient specifically in List. Accessing a linked list element by index requires iterating all prior elements.

@lawnjelly
Copy link
Member

It would be nice to remove the [] operator entirely from list, and fix all the misuse cases. I have a feeling it was discussed long ago, but there was some technical barrier (perhaps in some template requiring certain algorithms to be available).

@akien-mga akien-mga merged commit 81f3d43 into godotengine:master Feb 25, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@KoBeWi KoBeWi deleted the list_cringe branch February 25, 2024 11:37
@akien-mga akien-mga added the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Mar 9, 2024
@akien-mga
Copy link
Member

Cherry-picked for 4.2.2.

@akien-mga akien-mga removed the cherrypick:4.2 Considered for cherry-picking into a future 4.2.x release label Mar 9, 2024
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.

5 participants