Skip to content

perf: Optimize Query cache lookup and add CountEntities method - #313

Open
CorreRE wants to merge 1 commit into
genaray:masterfrom
CorreRE:master
Open

perf: Optimize Query cache lookup and add CountEntities method#313
CorreRE wants to merge 1 commit into
genaray:masterfrom
CorreRE:master

Conversation

@CorreRE

@CorreRE CorreRE commented Aug 24, 2026

Copy link
Copy Markdown

Summary

  • Query cache optimization: Use CollectionsMarshal.GetValueRefOrAddDefault (.NET 6+) to reduce dictionary lookups from two to one.
  • Add Query.CountEntities(): Convenience method to get entity count from a cached Query, avoiding the need to call World.CountEntities(queryDescription) separately.

Details

  • The optimization is conditionally compiled (#if NET6_0_OR_GREATER) and retains full compatibility with .NET Standard 2.1.
  • Both changes are fully backward compatible and pass existing tests.

…up (.NET 6+)

- Add Query.CountEntities() for allocation-free entity counting"
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.

1 participant