Skip to content

Replacing selectforview#50

Merged
aed3 merged 9 commits into
mainfrom
replacing-selectforview
Jun 8, 2026
Merged

Replacing selectforview#50
aed3 merged 9 commits into
mainfrom
replacing-selectforview

Conversation

@aed3

@aed3 aed3 commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Closes #49

aed3 added 9 commits May 29, 2026 17:26
The `EntityFilter` struct will be used to replace the `SelectForView`
and most of the `RegistryContainer` code as a simpler way to keep track
of entities that should be acted on. Instead of saving a list of what
components need to be selected and using the same tag to mark the
currently selected ones, any function that wants to work on a subset of
entities based on tags needs their caller to assign that entity before
calling. The `EntityFilter`'s job is simply to make it easier to run
views or groups over those chosen tags without needing to type that tag
all over the function.

This commit is making sure the filter works by replacing a small
`SelectForView` usage with it. The one replaced also tests a feature
that adds a tag based on pre-existing components as, on rare occasions,
a component that isn't used in the systems being called is part of the
filter.
This had a decent speed improvement for simulate turn, but not the other
two. That makes sense as the others are not set up to test for speed
with calculating crits. Also, the function wasn't tested, so I've add
scenarios to the calculate damage tests.
Profiling showed this function was one of the biggest time sinks due to
the old selection. Replacing that with the EntityFilter over doubled the
speed of the 8000+ input benchmarks.
Those two files and the functions they call no longer use
`SelectForView`. The result is a giant speed improvement for large input
counts, with the most being the 65536 inputs benchmark becoming 5 times
faster! The best part is the larger input counts now no longer greatly
increase their time per input times as inputs increase. That's a very
good sign and it makes me wonder how much the random input benchmarks
would be improving if they could reach those high entity counts.
Analyze effect is just an extension of CalcDamage, so removing
SelectForView is both simple and had no speed implications.
This removes all remaining uses of SelectForView and the files that
defined/tested it. The big change in Analyze Effect speeds for larger
one battle many inputs benchmarks is from changing SkippedInputCount to
the correct, larger type. The previous type was too small to hold the
correct value, so way more clones were being made than were needed.
I looked over the code to find places the event filters may be
incorrect. A few were found, but most of these changes are small ones
that should've been addressed.

I suspect the benchmark speed improvements come from changing
`emplace_or_replace` to `emplace` in CalcDamage.cpp
@aed3 aed3 self-assigned this Jun 8, 2026
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

🤖 Passed All One Review Bot Checks ✔️

@aed3 aed3 merged commit ef72465 into main Jun 8, 2026
70 checks passed
@aed3 aed3 deleted the replacing-selectforview branch June 8, 2026 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replacing SelectForView method of selecting entities

1 participant