-
Notifications
You must be signed in to change notification settings - Fork 175
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
CustomItemsUnhold & CustomItemsHolded #2685
Conversation
@@ -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(); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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()
?)
There was a problem hiding this 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
Requested review from nao to make sure that making this hash set was intended or not |
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