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

CustomItemsUnhold & CustomItemsHolded #2685

Merged
merged 2 commits into from
Jul 12, 2024

Conversation

Banalny-Banan
Copy link
Contributor

Current name is a bad one, calling .ToHashSet() every time property is accessed is heavily unoptimized, as it basicaly calls HashSet.Add for every item

@@ -64,12 +64,12 @@ public abstract class CustomItem : CustomModule, IAdditiveBehaviour
/// <summary>
/// Gets all pickups belonging to a <see cref="CustomItem"/>.
/// </summary>
public static HashSet<Pickup> CustomItemsUnhold => PickupManager.Keys.ToHashSet();
public static IEnumerable<Pickup> CustomPickups => PickupManager.Keys.ToHashSet();
Copy link
Contributor Author

@Banalny-Banan Banalny-Banan Jul 9, 2024

Choose a reason for hiding this comment

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

HashSets are usually prefered cause of their O(1) search, but here it is nowhere close to being O(1) as it is O(n) just to access cause of ToHashSet() call, so i think it is reasonable to make it IEnumerable

Copy link
Contributor

@VALERA771 VALERA771 Jul 10, 2024

Choose a reason for hiding this comment

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

I don't think that this is necessarily. Value will still be hash set so nothing will change (or you forgot to remove ToHashSet()?)

@Banalny-Banan Banalny-Banan marked this pull request as ready for review July 9, 2024 23:46
@louis1706 louis1706 added the regarding-api An issue or PR targeting the Exiled API project label Jul 10, 2024
Copy link
Member

@louis1706 louis1706 left a comment

Choose a reason for hiding this comment

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

take care of Valera request

@VALERA771 VALERA771 requested a review from NaoUnderscore July 10, 2024 17:21
@VALERA771
Copy link
Contributor

Requested review from nao to make sure that making this hash set was intended or not

@NaoUnderscore NaoUnderscore merged commit fdefe6e into Exiled-Team:dev Jul 12, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regarding-api An issue or PR targeting the Exiled API project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants