You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Critical bug in the DraftGizmos.GetGizmosPostfix() patch #142
It incorrectly expects the incoming sequence's item type to be Verse.Command when the original code works with its base class Verse.Gizmo. This breaks terribly when an item of such type is encountered in the sequence.
Additionally, it is inefficient in that 1) effectively causes double enumeration of the input sequence, 2) it constantly fetches the command icon instead of loading it once in the static constructor. I suggest you rewrite the function using the iterator protocol. Instead of copying the sequence into a list and then working on this copy make it yield every input item from the input sequence and when the condition is satisfied also yield the new gizmo.
It would look like this:
Addendum: it would also be good to avoid creating the new gizmo until the condition is satisfied, using the null conditional assignment so it is created at most once throughout the whole patch. Otherwise it causes unnecessary allocations to be garbage-collected later, in time-critial code.
I see that you had fixed the primary issue recently, but the code still has performance issues. I can't stress this nearly enough that is is executed in a time-critical game loop and it is imperative that it is as lightweight as possible. Avoiding pointless allocations would be a big help in this regard, not to mention the unneeded double enumeration of the sequence it entails.
Activity
ZzZombo commentedon Aug 9, 2025
I see that you had fixed the primary issue recently, but the code still has performance issues. I can't stress this nearly enough that is is executed in a time-critical game loop and it is imperative that it is as lightweight as possible. Avoiding pointless allocations would be a big help in this regard, not to mention the unneeded double enumeration of the sequence it entails.
ZzZombo commentedon Aug 22, 2025
@Taranchuk, @juanosarg, please take a look at the comment above.