Skip to content

Fix unnecessary leaderboard entry position bumping#175

Merged
tudddorrr merged 1 commit intodevelopfrom
no-unnecessary-position-bumping
Feb 22, 2026
Merged

Fix unnecessary leaderboard entry position bumping#175
tudddorrr merged 1 commit intodevelopfrom
no-unnecessary-position-bumping

Conversation

@tudddorrr
Copy link
Contributor

No description provided.

@tudddorrr tudddorrr added the fix This pull request contains a fix label Feb 22, 2026
@claude
Copy link

claude bot commented Feb 22, 2026

This fix is correct and the logic is sound. A few observations:


🔵 Minor: Loop bumps entries beyond the collision unnecessarily

The new loop runs from collisionIndex to the end of the list, bumping all subsequent entries — including those at positions well beyond the collision point.

For example: entries [A@0, B@1, C@3], upsert D@1:

  • D inserts, collisionIndex points to B@1
  • Loop bumps B@1→2 (correct) and C@3→4 (unnecessary — no entry displaced C)

The old foreach had identical behaviour, so this is pre-existing rather than a regression. But the new code was an opportunity to fix it too:

// Only bump entries that are contiguous with the collision
for (int i = collisionIndex; i < entries.Count; i++)
{
    if (entries[i].id == upsertEntry.id) continue;
    if (i > collisionIndex && entries[i].position != entries[i - 1].position + 1) break;
    entries[i].position += 1;
}

Whether that scope belongs in this PR is a judgment call — the stated fix (no-bump on same-position improvement) is correct as-is.


🔵 Minor: Missing test for a displaced entry scenario

The new test only covers the "no collision" path. There is no test verifying that entries at positions above the collision are (or are not) bumped when a genuine displacement occurs. The existing UpsertEntry_BumpPositions_OnlyBumpsAffectedEntries may cover this, but it predates the refactor so it is worth confirming it still exercises the new code path correctly.


Overall the core fix — using FindIndex for a collision check rather than bumping on position >= entry.position — is correct and well-targeted.

@tudddorrr tudddorrr force-pushed the no-unnecessary-position-bumping branch from 5156299 to 2a71cd7 Compare February 22, 2026 01:28
@tudddorrr tudddorrr merged commit 8140ddb into develop Feb 22, 2026
2 checks passed
@tudddorrr tudddorrr deleted the no-unnecessary-position-bumping branch February 22, 2026 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix This pull request contains a fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant