Skip to content

Fix flyweight key collisions between distinct cards - #515

Open
adityajai119 wants to merge 1 commit into
faif:masterfrom
adityajai119:fix-flyweight-key-collision
Open

adityajai119 wants to merge 1 commit into
faif:masterfrom
adityajai119:fix-flyweight-key-collision

Conversation

@adityajai119

Copy link
Copy Markdown

Card used value + suit as its flyweight pool key. Distinct cards with the same concatenation, for example ("1", "23") and ("12", "3"), shared one key, so the second lookup returned the first card with the wrong value and suit.

Use the (value, suit) tuple as the pool key.

Verification:

  • Added a regression test that fails before the fix and passes after.
  • python -m pytest tests/structural/test_flyweight.py - 3 passed.
  • Full suite: 100 passed.
  • python -m ruff check on both changed files reports only the two findings already present on unmodified upstream.

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