Fix error when a mixin missing a target has an inner class#163
Fix error when a mixin missing a target has an inner class#163Chocohead wants to merge 1 commit intoFabricMC:mainfrom
Conversation
Doesn't crash-crash, but will refuse to apply the mixin on any non-missing targets
|
This seems to be 2 changes: fixing the bug, and avoiding empty list iterations. I agree with the first but not with the second, seems like a divergence for the sake of micro-optimization. Can we just fix the bug? |
|
The optimisation scales quadratically with the number of targets a mixin has:
Loading large modpacks (such as Blanketcon-25) with Not So New will produce a mixin with target counts in this kind of range. At this scale the optimisation is not micro anymore. Whilst I will happily admit it's hardly a common use, this PR pushes the problem down to people with mixins with huge target counts and inner classes, which is an even less common use, at no expense to the standard uses. It also should make profiling a little easier to find what is still so slow in my use. |
|
Why not swap the loops around so the inner class one is on the outside? |
|
Though as a general point I'm quite against diverging from upstream to optimise things purely for the sake of Not So New, which as far as I can ascertain has no practical use other than curiosity. |
|
Ironically I'd left the loops that way around to minimise the changes to what was already there. The divergence from upstream is when the bug is fixed, from that point changing the lines immediately around it is inconsequential given it all forms a single patch together anyway. Nothing is stopping this change from going into upstream either; beyond the glacial pace anything is pushed there to begin with. Although were upstream in the mood for fixing this, it should really be done by |
I agree, but your suggestion also adds an extra method to MixinInfo and mine doesn't. |
|
Adding is much less consequential, it just has to fit somewhere around what is already there, as opposed to patched on top of what is there. It would get much more micro-optimisation-y if a |
When a mixin has multiple target classes and at least one is missing, as well as at least one inner class to merge into the targets, Mixin would previously throw an error when applying the mixin to any target.
Using the following mixin:
would produce the following log upon trying to load
Target:This PR corrects this by avoiding resolving each target's
ClassInfoevery time a mixin is loaded, making the most of the targets having already been resolved when the mixin config was selected. It also avoids iterating the targets list at all when a mixin has no inner classes, given most mixins will not.