feat: add boss bar viewer#1756
Conversation
|
Why does |
| } | ||
|
|
||
| @Override | ||
| public @UnmodifiableView @org.jspecify.annotations.NonNull Iterable<? extends BossBar> activeBossBars() { |
There was a problem hiding this comment.
| public @UnmodifiableView @org.jspecify.annotations.NonNull Iterable<? extends BossBar> activeBossBars() { | |
| public @UnmodifiableView @NonNull Iterable<? extends BossBar> activeBossBars() { |
org.checkerframework.checker.nullness.qual.NonNull is imported
What are you talking about? |
yes but you're treating it as a monotonically non-null value. we can just leave it as a private final Set<BossBar> bossBars = new HashSet<>();and omit any null checks down the line. keeping this value null until it's used doesn't seem like it'll affect performance at all, and it makes the code that's using this field less readable (null -> either instantiate this set when modifying it, or assuming an empty set when querying it) |
|
They don't though (https://github.com/PaperMC/Velocity/pull/1756/changes#diff-1cd097c1de92fff8c43bc33eb4f52405eb5396f9e8cc922a4502e4cad12e1f88R613), or am I missing something? |
oh yes my bad, its not monotonically non-null, but my point still holds. this can be a HashSet that's initiated once (at construct time of the object) and only updated/queried without null-checks. that'd get rid of null-checks in every method that's using this field |
No description provided.