Skip to content

ListTag improvements#91

Open
HoldYourWaffle wants to merge 8 commits intoQuerz:nbt7from
HoldYourWaffle:listtag-improvements
Open

ListTag improvements#91
HoldYourWaffle wants to merge 8 commits intoQuerz:nbt7from
HoldYourWaffle:listtag-improvements

Conversation

@HoldYourWaffle
Copy link
Contributor

Title says it all :)
I'd recommend reviewing this per-commit. The non-trivial ones have explanations in the message.

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()) {
Copy link
Owner

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

Copy link
Contributor Author

@HoldYourWaffle HoldYourWaffle Jun 1, 2023

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.

Copy link
Contributor Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants