Skip to content

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

Merged
genaray merged 1 commit into
genaray:masterfrom
CorreRE:master
Sep 22, 2026
Merged

genaray merged 1 commit into
genaray:masterfrom
CorreRE:master

Conversation

@CorreRE

@CorreRE CorreRE commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

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"
@genaray
genaray merged commit 9eb9ff2 into genaray:master Sep 22, 2026
8 checks passed
@genaray

genaray commented Sep 22, 2026

Copy link
Copy Markdown
Owner

Thanks! :)

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.

2 participants