baritone icon indicating copy to clipboard operation
baritone copied to clipboard

Use immutable collections for settings

Open ZacSharp opened this issue 3 years ago • 3 comments

Using an ImmutableSet seems to be faster according to this benchmark, but that would either require a breaking API change or improperly making the settings ImmutableSets while exposing only their list views (i.e. lists that behave as ordered sets, which currently works because we only use them as ordered sets).

ZacSharp avatar Jul 03 '22 02:07 ZacSharp

Seems like this would really help with #3479. Are there any downsides?

Also I don't care about breaking API changes as long as impact client isn't affected 😈 (joke) (but only sorta)

leijurv avatar Jul 05 '22 22:07 leijurv

Others can still put in their own implementations like

BaritoneAPI.getSettings().acceptableThrowawayItems.value = new ArrayList<>();
// some time later
BaritoneAPI.getSettings().acceptableThrowawayItems.value.add(net.minecraft.init.Blocks.DIAMOND_BLOCK);

or even the unrealistic

BaritoneAPI.getSettings().acceptableThrowawayItems.value = new MyCursedListThatRandomlyRepopulatesOnEveryAccess<>();

which both screw up the caching and in the latter case even the current implementation. Apart from that there's nothing coming to my mind.

ZacSharp avatar Jul 11 '22 19:07 ZacSharp

Is any of those scenarios or something else holding this back?

ZacSharp avatar Oct 04 '22 23:10 ZacSharp