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 List swap behavior on front, back and adjacent elements #42013

Merged
merged 2 commits into from
Sep 16, 2020
Merged

Fix List swap behavior on front, back and adjacent elements #42013

merged 2 commits into from
Sep 16, 2020

Conversation

Xrayez
Copy link
Contributor

@Xrayez Xrayez commented Sep 12, 2020

This fixes #41981 List swap behavior on front, back and adjacent elements.

  • immediately return if A == B;
  • first and last elements (front, back) are updated upon re-linking, and only when needed.
  • handles a case of forward and backward adjacent elements (A↔B, B↔A).

I've added a test suite for List to test out these changes (both normal and stress tests) in a separate commit, so you can verify the fix more easily and perhaps make it easier to cherry-pick this to 3.2, but I can revert that commit and move everything to #41982 instead.

I've stumbled upon this bug while trying to port existing Godot List implementation to scripting in goostengine/goost#12.

Andrii Doroshenko (Xrayez) added 2 commits September 12, 2020 23:58
- immediately return if A == B;
- first and last elements (front, back) are updated upon relinking;
- handles a special case of forward and backward adjacent elements.
Adds a number of test cases for `List::swap()`.
@Calinou Calinou added this to the 4.0 milestone Sep 12, 2020
@akien-mga akien-mga merged commit 6ac7b90 into godotengine:master Sep 16, 2020
@akien-mga
Copy link
Member

Thanks!

@akien-mga akien-mga added the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Sep 16, 2020
@Xrayez Xrayez deleted the fix-list-swap branch September 16, 2020 15:40
@akien-mga akien-mga added archived cherrypick:3.x Considered for cherry-picking into a future 3.x release and removed cherrypick:3.x Considered for cherry-picking into a future 3.x release archived labels Sep 18, 2020
@akien-mga
Copy link
Member

Cherry-picked for 3.2.4.

@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Sep 24, 2020
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.

List incorrect swap behavior of front and back
3 participants