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

ListTag improvements #91

Open
wants to merge 8 commits into
base: nbt7
Choose a base branch
from

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