Skip to content

Two of RefreshFull's three branches are unreachable, and the EcsView ctor that would reach one has no callers #668

Closed

Description

@nockawa

Found while fixing #663, which required reasoning about every RefreshFull branch.

EcsView<T>.RefreshFull has three branches:

if (HasCachedPlanInternal && _fieldReader != null)   // (1) cached-plan scan
else if (_fieldReader != null)                        // (2) broad scan via EcsQuery.Execute()
else                                                  // (3) pull mode: re-query

Only (1) is reachable.

  • (2) requires a field reader with no cached plan. The only constructor producing that shape — EcsView.cs:40, (query, evaluators, componentTable, fieldReader, bufferCapacity, …) — has no callers. EcsQuery constructs views at exactly three sites: ToPullView (allocator ctor, :91), ToIncrementalView (plan ctor, :54), ToOrView (plans ctor, :69).
  • (3) requires _fieldReader == null, i.e. a pull view. But Refresh returns for pull mode at EcsView.cs:245-252 (Evaluators.Length == 0 → RefreshPull) before the overflow check that calls RefreshFull.

Why it matters beyond dead code

The unreachable branch (2) was the correct one for cluster-backed archetypes — it went through EcsQuery.Execute(), which knew about the per-archetype index home — while the reachable branch (1) did not. #663's issue text described the site as "correct or broken depending on whether a cached plan exists"; in fact it was always broken, because the correct branch cannot be reached. Dead code that looks like a fallback hides how narrow the live path really is.

Proposed

  • Delete the unused EcsView.cs:40 constructor and branch (2).
  • Delete branch (3), or replace it with a Debug.Assert recording that pull views never reach RefreshFull.
  • Confirm no reflection / test-only construction depends on the removed ctor first.

Pre-alpha: clean deletion, no deprecation shim.

Parent context: #629.

Activity

  1. self-assigned this
    on Aug 3, 2026
  2. added theissue type on Aug 3, 2026
  3. moved this to Todo in Typhonon Aug 6, 2026
  4. nockawa commented on Aug 12, 2026

    @nockawa
    CollaboratorAuthor

    Folding this into the #722 / #790 / #791 change — same method, and that work rewrites the pull path this issue is about.

    One correction to the analysis above, found while measuring #790. Branch (3) is described here as unreachable because Refresh returns for pull mode at EcsView.cs:245-252 before the overflow check. That is still true, but the reason it matters has changed: the pull path is about to stop being "re-query and diff" and become an occupancy-delta path, so branch (3) is not merely dead — it encodes a fallback that will no longer be the correct shape for a pull view at all.

    Plan for this issue inside that PR:

    • Delete the EcsView.cs:40 constructor and branch (2) as proposed (confirmed no callers, including tests).
    • Replace branch (3) with a Debug.Assert rather than deleting it silently, since the new pull path makes "a pull view reached RefreshFull" a real invariant violation worth catching rather than an impossible state.
  5. moved this from Todo to In Progress in Typhonon Aug 12, 2026
  6. nockawa commented on Aug 13, 2026

    @nockawa
    CollaboratorAuthor

    Done in PR #795 (rides with #722's visibility-gate work, since both touch EcsView).

    Both unreachable branches are gone, along with the EcsView constructor that produced the only shape one of them handled — it had no callers, confirmed against all three new EcsView<> sites. The surviving branch is now asserted rather than selected, so a pull view reaching RefreshFull fails loudly instead of silently rebuilding a predicate-filtered set without evaluating the predicate.

    Worth recording why this was more than tidying: one of the dead branches was the correct one for cluster-backed archetypes. That is what made #663 read as "correct or broken depending on whether a plan exists" when it was always broken — dead code shaped like a fallback hid how narrow the live path actually was.

  7. added a commit that references this issue on Aug 13, 2026
  8. moved this from In Progress to Done in Typhonon Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Fields

Priority

None yet

Estimate

None yet

Area

None yet

Product

None yet

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions