Skip to content
This repository was archived by the owner on Feb 18, 2024. It is now read-only.

Conversation

@awoo-civ
Copy link

@awoo-civ awoo-civ commented Dec 18, 2023

The LinkedList of clickables will contain as many entries as there are snitches to display, so potentially thousands.

Then this loop will call .get() on the list ~45 times per page. Because it's a linked list, each .get() will be O(n). Moreover, because it's not just iterating through the list, but rather incrementing an integer and calling .get(i), the performance is as bad as can be.

The list never seems to get modified after creation, so there's literally no benefit to using a linked list over an array here, only massive downsides.

Not tested 🤷🏽‍♀️

The LinkedList of `clickables` will contain as many entries as there are snitches to display, potentially thousands.

Then this loop https://github.com/CivMC/CivModCore/blob/master/paper/src/main/java/vg/civcraft/mc/civmodcore/inventory/gui/MultiPageView.java#L47 will call `.get()` on the list ~45 times per each page. Because it's a linked list, each `.get()` will be O(n). Pretty bad.

The list never seems to get modified after creation, so there's literally no benefit to use a linked list over an array here, only massive downsides.
Co-authored-by: okx-code <okx@okx.sh>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants