Skip to content

Critical bug in the DraftGizmos.GetGizmosPostfix() patch #142

@ZzZombo

Description

@ZzZombo

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: Image

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.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions