Remove redundant component tracking. #19147
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What Does This PR Do
Fixes #19130.
This PR excludes
/datum/component
from the list of types when checking for duplicate datum components.This issue manifested itself in the failure to GC of
/obj/structure/spider/spiderlings
, which was traced back to the failure to find a reference to the/datum/component/spawning
component attached on Initialize. However, this issue has always been present; when inspecting thedatum_components
of any object, the values will look something like this:As you can see, Paperwork has two components, but his
datum_components
also includes a list of his components.This is because the absence of
/datum/component
in the list was considered an absence of each subcomponent respectively. They are added to a list because of how the component system handles 'duplicates', components of the same subtype. Depending on the component'sdupe_mode
, it may attempt to merge the two, clobber one with the other, or allow the presence of both added to a list in the datum_components list, with the key being the component type, and the list values being instances of the component.What's weird is
/datum/component/proc/_GetInverseTypeList
, which is where the registrar gets the list of subtypes to check. It is reproduced in its entirety below:I don't really understand the comment; it seems to understand that it would in fact be included
/datum/component
in the results (1: "most components are root level + 1", 2: it adds the parent_type to the list first thing). So it sounds as if the behavior is intended. But I'm confident that the existing behavior is broken. Even more confusing, I can't find any components that are second level children of/datum/component
, so I don't know why it's looking at all. But if it is indeed the case that a/datum/component/foo/bar/baz
exists, we can't just remove the assignation of the parent type to the list here. We have to check after the fact.I also don't know why
/datum/component
'sdupe_mode
ofCOMPONENT_DUPE_HIGHLANDER
(i think it just lets the latest version win) doesn't cause any issues here, instead obediently adding each subcomponent in turn to what it believes is a list of duplicate components.This also removes an unnecessary list allocation to any object with a component. This may provide a negligible performance boost.
Why It's Good For The Game
GC failures are bad
Images of changes
Testing
Spawned 100 spiderlings, waited for them to grow up, inspected del log.
Before:

After:
Changelog
🆑
fix: Fixed an issue which prevented spiderlings from GC'ing
/:cl: