-
Notifications
You must be signed in to change notification settings - Fork 48
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
ListTag improvements #91
base: nbt7
Are you sure you want to change the base?
Conversation
The implementation of TypedListTag fully supports mutation with the necessary validation checks, so it's purpose isn't just iteration (anymore).
There's nothing inherently wrong with a typed but empty list, as long as it's properly serialized. Resetting a ListTag's type when it runs empty circumvents pollution checks, meaning a ListTag could (accidentally) change its type, which feels like asking for trouble :)
Git seems to generate a very unfortunate diff for this...
De-dupes validation logic. Modifying a passed in list circumvented validation. It's still possible to modify a `ListTag` using the `List`-interface via `asList`.
return ((NumberTag) tag).asByte(); | ||
} | ||
public Tag getTagOrNull(int index) { | ||
if (index < value.size()) { |
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.
this is missing the check that index is >= 0
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 had this initially, but decided that if you're passing in a negative index something must've gone so horribly wrong somewhere that it makes more sense to fail fast. This is consistent with other libraries like guava's Iterables.get
.
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.
Sorry I've been gone for a while, how do you feel about this now @Querz?
Title says it all :)
I'd recommend reviewing this per-commit. The non-trivial ones have explanations in the message.